2025-02-10 01:58:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2025-02-16 21:11:07 +02:00
|
|
|
use App\Models\Season;
|
2025-02-10 01:58:12 +02:00
|
|
|
use App\Models\Show;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class ShowController extends Controller
|
|
|
|
|
{
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$shows = Show::paginate(48);
|
|
|
|
|
|
|
|
|
|
return view('show.index', compact('shows'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function show(string $slug)
|
|
|
|
|
{
|
|
|
|
|
$show = Show::with('posters', 'backdrops', 'externalIds', 'networks', 'genres', 'productionCompanies')->where('slug', $slug)->first();
|
|
|
|
|
|
|
|
|
|
$comments = [];
|
|
|
|
|
|
2025-02-16 21:11:07 +02:00
|
|
|
$seasons = Season::where('show_id', $show->id)->orderBy('season_number', 'ASC')->get();
|
|
|
|
|
|
|
|
|
|
return view('show.show', compact('show', 'comments', 'seasons'));
|
2025-02-10 01:58:12 +02:00
|
|
|
}
|
2025-08-07 23:01:58 +03:00
|
|
|
|
|
|
|
|
public function season(string $slug, int $seasonNumber)
|
|
|
|
|
{
|
2025-09-06 14:41:10 +03:00
|
|
|
$show = Show::with('posters', 'backdrops', 'externalIds', 'networks', 'genres', 'productionCompanies')->where('slug', $slug)->first();
|
2025-08-07 23:01:58 +03:00
|
|
|
|
2025-09-06 14:41:10 +03:00
|
|
|
if (!$show) {
|
|
|
|
|
abort(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$seasons = Season::where('show_id', $show->id)->orderBy('season_number', 'ASC')->get();
|
|
|
|
|
$currentSeason = Season::where('show_id', $show->id)->where('season_number', $seasonNumber)->first();
|
|
|
|
|
|
|
|
|
|
if (!$currentSeason) {
|
|
|
|
|
abort(404);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$episodes = \App\Models\Episode::where('show_id', $show->id)
|
|
|
|
|
->where('season_id', $currentSeason->id)
|
|
|
|
|
->orderBy('episode_number', 'ASC')
|
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
$comments = [];
|
|
|
|
|
|
|
|
|
|
return view('show.season', compact('show', 'seasons', 'currentSeason', 'episodes', 'comments'));
|
2025-08-07 23:01:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function episode(string $slug, int $seasonNumber, int $episodeNumber)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
2025-02-10 01:58:12 +02:00
|
|
|
}
|