mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-04-27 05:50:51 -05:00
refactor: crudify torrent controller
- routes to be cleaned up at end of controller refactors
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* NOTICE OF LICENSE.
|
||||
*
|
||||
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
|
||||
* The details is bundled with this project in the file LICENSE.txt.
|
||||
*
|
||||
* @project UNIT3D Community Edition
|
||||
*
|
||||
* @author HDVinnie <hdinnovations@protonmail.com>
|
||||
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Movie;
|
||||
use App\Models\Torrent;
|
||||
use App\Models\Tv;
|
||||
|
||||
class SimilarTorrentController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*/
|
||||
public function show(int $categoryId, int $tmdbId): \Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View|\Illuminate\Contracts\Foundation\Application
|
||||
{
|
||||
$torrent = Torrent::where('category_id', '=', $categoryId)
|
||||
->where('tmdb', '=', $tmdbId)
|
||||
->first();
|
||||
|
||||
\abort_if(! $torrent || $torrent->count() === 0, 404, 'No Similar Torrents Found');
|
||||
|
||||
$meta = null;
|
||||
if ($torrent->category->tv_meta) {
|
||||
$meta = Tv::with('genres', 'cast', 'networks', 'seasons')->where('id', '=', $tmdbId)->first();
|
||||
}
|
||||
|
||||
if ($torrent->category->movie_meta) {
|
||||
$meta = Movie::with('genres', 'cast', 'companies', 'collection')->where('id', '=', $tmdbId)->first();
|
||||
}
|
||||
|
||||
return \view('torrent.similar', [
|
||||
'meta' => $meta,
|
||||
'torrent' => $torrent,
|
||||
'categoryId' => $categoryId,
|
||||
'tmdbId' => $tmdbId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user