Merge pull request 'add-show-page' (#1) from add-show-page into main

Reviewed-on: costin/playlab#1
This commit is contained in:
Constantin Plaiasu 2024-08-26 22:14:18 +03:00
commit 852c2f5993
13 changed files with 267 additions and 38 deletions

View file

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Http\Requests\ShowRequest;
use DipeshSukhia\LaravelHtmlMinify\LaravelHtmlMinifyFacade;
use Illuminate\Http\Request;
use App\Services\ApiClient;
@ -23,14 +24,14 @@ class ShowController extends Controller
{
use CleanItems, TopContent;
public function index(TmdbClient $tmdb, ApiClient $api, int $id, string $slug = null )
public function index(TmdbClient $tmdb, ApiClient $api, int $id, string $slug)
{
$airing = [];
$call = function() use($tmdb, $id, &$season, &$airing){
$id = self::decodeId($id);
$show = $tmdb->getShow($id);
$data = $tmdb->getShow($id);
$data = $this->formatTmdbShow($show);
$airing = $this->formatTmdbResponse($tmdb->getAiringShows(1), false, [], 12)['data'];
return $data;
};
@ -55,7 +56,7 @@ public function index(TmdbClient $tmdb, ApiClient $api, int $id, string $slug =
}
public function season(TmdbClient $tmdb, ApiClient $api, int $id, int $season = null, string $slug = null )
public function season(TmdbClient $tmdb, ApiClient $api, int $id, string $slug = null, int $season = null )
{
$airing = [];
$is_show_page = is_null($season);

View file

@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class ShowRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
return [
'id' => 'numeric|required',
'slug' => 'string|required',
];
}
}

View file

@ -110,7 +110,7 @@ public static function getShowSchema(array $movie): array
return Schema::person()->name($actor['name'])->image($actor['image']);
})->values()->all();
$movieSchema->actor($actors);
$directors = collect($movie->crew)->filter(fn ($director) => Str::of($director['as'])->contains('producer', true))->map(function ($director) {
$directors = collect($movie->crew['producers'])->filter(fn ($director) => Str::of($director['as'])->contains('producer', true))->map(function ($director) {
return Schema::person()->name($director['name'])->image($director['image']);
})->values()->all();
$movieSchema->producer($directors);

View file

@ -95,13 +95,15 @@ public function formatTmdbShow($data):array
$show['vote_count'] = $data['vote_count'];
$show['number_of_episodes'] = $data['number_of_episodes'];
$show['number_of_seasons'] = $data['number_of_seasons'];
$show['poster'] = $this->getImageUrl($data['poster_path'], 'w500', 230, 345);
$show['poster'] = $this->getImageUrl($data['poster_path'], 'w500', 300, 450);
$show['backdrop'] = $this->getImageUrl($data['backdrop_path'], 'w1280', 1280, 720);
$show['backdrop_path'] = $data['backdrop_path'];
$show['first_air_date'] = $this->formatReleaseDate($data['first_air_date']);
$show['year'] = $this->formatDateYear($data['first_air_date']);
$show['genres'] = $this->formatGenres($data['genres']);
$show['cast'] = $this->getCast($data['credits']['cast'] ?? [], 8);
$show['creators'] = $this->getCreators($data['created_by'] ?? [], 8);
$show['crew'] = $this->getCrew($data['credits']['crew'] ?? [], 8);
$show['crew']['creators'] = $this->getCreators($data['created_by'] ?? [], 8);
$show['crew']['producers'] = $this->getCrew($data['credits']['crew'] ?? [], 8);
$show['runtime'] = isset($data['episode_run_time'][0]) ? CarbonInterval::make($data['episode_run_time'][0], 'minute')->cascade()->forHumans(['short' => true]) : false;
$show['duration'] = isset($data['episode_run_time'][0]) ? CarbonInterval::make($data['episode_run_time'][0], 'minute')->totalSeconds : false;
$show['countries'] = collect($data['production_countries'])->implode('name', ', ');
@ -112,8 +114,10 @@ public function formatTmdbShow($data):array
unset($season['poster_path']);
return $season;
})->values()->all();
$show['similar'] = $this->formatTmdbResponse($data['recommendations'], false, [], 6)['data'] ?? [];
$show['similar'] = $this->formatTmdbResponse($data['recommendations'], false, [], 8)['data'] ?? [];
$show['keywords'] = $data['keywords']['results'] ?? [];
$show['languages'] = self::getSpokenLanguages($data['spoken_languages']);
$show['share'] = self::getShareLinks(route('movie', ['id' => $show['id'], 'slug' => $show['slug']]), $show['title'], Str::limit($show['overview'], 100), $show['poster']);
// dd($show);
return $show;

View file

@ -66,6 +66,10 @@ public static function formatReleaseDate(?string $release_date): string
{
return Carbon::parse($release_date)->format('M d, Y');
}
public static function formatDateYear(?string $release_date): string
{
return Carbon::parse($release_date)->format('Y');
}
public static function formatGenres(array $genres, $type = 'movie'): array
{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
/*!
* Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
* License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
*/.fa,.fas,.far{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}@keyframes fa-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fa-database:before{content:""}.fa-expand:before{content:""}.fa-expand-alt:before{content:""}.fa-expand-arrows-alt:before{content:""}.fa-eye:before{content:""}.fa-paper-plane:before{content:""}.fa-play:before{content:""}.fa-play-circle:before{content:""}.fa-playstation:before{content:""}.fa-search:before{content:""}.fa-search-dollar:before{content:""}.fa-search-location:before{content:""}.fa-search-minus:before{content:""}.fa-search-plus:before{content:""}.fa-searchengin:before{content:""}.fa-star:before{content:""}@font-face{font-family:"Font Awesome 5 Brands";font-style:normal;font-weight:400;font-display:block;src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.eot);src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.eot?#iefix) format("embedded-opentype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.woff2) format("woff2"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.woff) format("woff"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.ttf) format("truetype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.svg#fontawesome) format("svg")}@font-face{font-family:"Font Awesome 5 Free";font-style:normal;font-weight:400;font-display:block;src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.eot);src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.eot?#iefix) format("embedded-opentype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.woff2) format("woff2"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.woff) format("woff"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.ttf) format("truetype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.svg#fontawesome) format("svg")}.far{font-family:"Font Awesome 5 Free";font-weight:400}@font-face{font-family:"Font Awesome 5 Free";font-style:normal;font-weight:900;font-display:block;src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.eot);src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.eot?#iefix) format("embedded-opentype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.woff2) format("woff2"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.woff) format("woff"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.ttf) format("truetype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.svg#fontawesome) format("svg")}.fa,.fas{font-family:"Font Awesome 5 Free";font-weight:900}
*/.fa,.fas,.far{-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:inline-block;font-style:normal;font-variant:normal;text-rendering:auto;line-height:1}@keyframes fa-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.fa-database:before{content:""}.fa-expand:before{content:""}.fa-expand-alt:before{content:""}.fa-expand-arrows-alt:before{content:""}.fa-eye:before{content:""}.fa-paper-plane:before{content:""}.fa-play:before{content:""}.fa-play-circle:before{content:""}.fa-playstation:before{content:""}.fa-search:before{content:""}.fa-search-dollar:before{content:""}.fa-search-location:before{content:""}.fa-search-minus:before{content:""}.fa-search-plus:before{content:""}.fa-searchengin:before{content:""}.fa-star:before{content:""}.fa-unlock:before{content:""}@font-face{font-family:"Font Awesome 5 Brands";font-style:normal;font-weight:400;font-display:block;src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.eot);src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.eot?#iefix) format("embedded-opentype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.woff2) format("woff2"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.woff) format("woff"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.ttf) format("truetype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-brands-400.svg#fontawesome) format("svg")}@font-face{font-family:"Font Awesome 5 Free";font-style:normal;font-weight:400;font-display:block;src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.eot);src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.eot?#iefix) format("embedded-opentype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.woff2) format("woff2"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.woff) format("woff"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.ttf) format("truetype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-regular-400.svg#fontawesome) format("svg")}.far{font-family:"Font Awesome 5 Free";font-weight:400}@font-face{font-family:"Font Awesome 5 Free";font-style:normal;font-weight:900;font-display:block;src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.eot);src:url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.eot?#iefix) format("embedded-opentype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.woff2) format("woff2"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.woff) format("woff"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.ttf) format("truetype"),url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/webfonts/fa-solid-900.svg#fontawesome) format("svg")}.fa,.fas{font-family:"Font Awesome 5 Free";font-weight:900}

File diff suppressed because one or more lines are too long

View file

@ -36,7 +36,7 @@
"isEntry": true
},
"resources/scss/app.scss": {
"file": "assets/app-CCYkocot.css",
"file": "assets/app-CT5t3asE.css",
"src": "resources/scss/app.scss",
"isEntry": true
},

View file

@ -2087,7 +2087,8 @@ a:hover {
.movie-small__thumb img {
width: 100%;
height: 80px;
height: auto;
aspect-ratio: 2/3;
min-height: 80px;
object-fit: cover;
-o-object-fit: cover;
@ -2118,7 +2119,7 @@ a:hover {
.movie-list-scroll .movie-small__thumb img {
width: 100%;
height: 70px;
// height: 70px;
object-fit: cover;
-o-object-fit: cover;
object-position: center;

View file

@ -4,15 +4,213 @@
<script type="application/ld+json">{!!$value!!}</script>
@endforeach
@endsection
{{-- @section('head')
@section('head')
<link rel="preload" as="image" type="image/webp" href="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}}" imagesrcset="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}} 360w, {{img_url('w1280', $show['backdrop_path'], true, 1280, 720 )}} 1280w" imagesizes="70vw, 100vw" fetchpriority="high" />
<style>
{!! Vite::content('resources/scss/player.scss') !!}
{!! Vite::content('resources/scss/watch.scss') !!}
</style>
@endsection --}}
@endsection
{{-- @section('head') --}}
{{-- {!! getMovieMarkupData($movie) !!} --}}
{{-- {!! getMovieMarkupData($show) !!} --}}
{{-- @endsection --}}
@section('app')
<section class="inner-hero bg_img dark--overlay lazy main-watch" data-id="{{ $show['id'] }}" data-type="show">
<figure>
<img @if(isset($show['backdrop']) && $show['backdrop'] !== '') {{-- src="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}}" --}} data-srcset="{{img_url('w1280', $show['backdrop_path'], true, 360, 200 )}} 360w, {{img_url('w1280', $show['backdrop_path'], true, 1280, 720 )}} 1280w" class="lazy" @endif width="100%" height="720" alt="{{ str($show['title'])->apa() }} ({{ $show['year'] }})" src="data:image/svg+xml,%3Csvg width='1280' height='720' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1280' height='720' x='0' y='0' fill='%231B1B3F' /%3E%3C/svg%3E" data-sizes="70vw, 100vw">
</figure>
<div class="container position-relative">
<div class="row">
<div class="col-lg-12">
<h1 class="text-center">{{ str($show['title'])->apa() }}</h1>
@if($show['tagline'])
<p class="text-center fst-italic fs-5">"{{ $show['tagline'] }}"</p>
@endif
<ul class="page-breadcrumb d-flex justify-content-center">
<li><a href="{{route('home')}}" class="">Home</a></li>
<li><a href="{{route('shows')}}" class="">Series</a></li>
<li>{{$show['title']}}</li>
</ul>
</div>
</div>
</div>
</section>
<div class="pt-80 pb-80 position-relative">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="movie-content">
<div class="movie-content-inner d-sm-flex justify-content-between align-items-center flex-wrap">
<div class="movie-content-left">
<h2 class="title">Watch {{ str($show['title'])->apa() }}</h2>
<span class="sub-title">Type : <span class="cat"><a href="{{route('shows',['page' => null])}}">TV Show</a></span>
Seasons: {{ count($show['seasons']) }}
</span>
</div>
<div class="movie-content-right mt-sm-0 mt-3">
<div class="movie-widget-area align-items-center">
<span class="movie-widget">
<i class="lar la-star base--color"></i>
<span>{{$show['vote_average']}}</span>
</span>
<span class="movie-widget">
<i class="lar la-eye color--danger"></i>
<span>{{$show['vote_count']}} views</span>
</span>
<span class="movie-widget addWishlist " data-id="1207" data-type="item"><i class="las la-plus-circle"></i></span>
</div>
<ul class="title-share d-flex align-items-center justify-content-sm-end justify-content-start flex-wrap">
<li class="caption">Share : </li>
@if (isset($show['share']) && is_array($show['share']))
@foreach ($show['share'] as $share)
<li data-bs-toggle="tooltip" data-bs-placement="top" title="{{ $share['name'] }}">
<a href="{{ $share['url'] }}" target="_blank"><i class="lab {{ $share['icon'] }}"></i></a>
</li>
@endforeach
@endif
</ul>
</div>
</div>
</div>
<div class="movie-details-content">
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active" id="description" role="tabpanel" aria-labelledby="description-tab">
<div class="card mb-sm-3 col-12 order-sm-1 order-2 mt-3 p-0">
<div class="card-body">
<div class="row">
<div class="col-lg-6">
<h4 class="mb-3">Details</h4>
<p>{{ $show['overview'] }}</p>
<ul class="movie-details-list mt-3">
<li>
<span class="caption">Genres:&nbsp</span>
<span class="value">
@foreach($show['genres'] as $genre)
<span>{{ $genre['name'] }}</span>@if(!$loop->last), @endif
@endforeach
</span>
</li>
<li>
<span class="caption">Language:&nbsp</span>
<span class="value">
@foreach($show['languages'] as $language)
{{ $language }}@if(!$loop->last), @endif
@endforeach
</span>
</li>
</ul>
</div>
<div class="col-lg-6 mt-lg-0 mt-4">
<h4 class="mb-3">Cast & Crew</h4>
<ul class="movie-details-list">
<li>
<span class="caption">Cast:</span>
<span class="value">
@foreach($show['cast'] as $actor)
{{ $actor['name'] }}@if(!$loop->last), @endif
@endforeach</span>
</li>
<li>
<span class="caption">Creator:</span>
<span class="value">
@foreach($show['crew']['creators'] as $actor)
{{ $actor['name'] }}@if(!$loop->last), @endif
@endforeach
</span>
</li>
@unless (empty($show['crew']['producers']))
<li>
<span class="caption">Producer:</span>
<span class="value">
@foreach($show['crew']['producers'] as $actor)
{{ $actor['name'] }}@if(!$loop->last), @endif
@endforeach</span>
</li>
@endunless
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="card col-12 order-sm-2 order-1 p-0">
<div class="card-body p-0">
<div class="slimScrollDiv" style="position: relative; overflow: hidden; width: auto; height: 420px;">
<ul class="movie-small-list movie-list-scroll" style="overflow: hidden; width: auto; height: 420px;">
@foreach ($show['seasons'] as $currentSeason)
<li class="movie-small d-flex align-items-center justify-content-between movie-item__overlay video-item flex-wrap" data-img="https://script.viserlab.com/playlab/demo/assets/images/item/episode//2022/07/06/62c53342b113e1657090882.jpg" data-text="Season">
<div class="caojtyektj d-flex align-items-center flex-wrap">
<div class="movie-small__thumb">
<img src="{{ $currentSeason['poster'] }}" alt="image">
</div>
<div class="movie-small__content">
<h5>{{ $currentSeason['name'] }}</h5>
<a class="base--color" href="{{ route('show.season', ['id' => $show['id'], 'slug' => $show['slug'], 'season' => $currentSeason['season_number']]) }}">Play Now</a>
</div>
</div>
<div class="movie-small__lock">
<span class="movie-small__lock-icon">
<i class="fas fa-unlock"></i>
</span>
</div>
</li>
@endforeach
</ul>
<div class="slimScrollBar" style="background: rgb(0, 0, 0); width: 7px; position: absolute; top: 0px; opacity: 0.4; display: none; border-radius: 7px; z-index: 99; right: 1px; height: 110px;"></div><div class="slimScrollRail" style="width: 7px; height: 100%; position: absolute; top: 0px; display: none; border-radius: 7px; background: rgb(51, 51, 51); opacity: 0.2; z-index: 90; right: 1px;"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<section class="movie-section pb-80 position-relative">
<div class="container">
<div class="row">
<div class="col-xl-12">
<div class="section-header">
<h3 class="section-title">Similar Titles</h3>
</div>
</div>
</div>
<div class="row justify-content-center mb-30-none">
@foreach ($show['similar'] as $item)
@include('components.title_card', ['data_text' => ucfirst($item['type'])])
@endforeach
</div>
</div>
</section>
@endsection
@section('footer')
@vite(['resources/js/watch.js'])
@endsection
@section('content')
<nav aria-label="breadcrumb">
<ol class="breadcrumb mt-3">
@ -65,15 +263,15 @@
{{ $actor['name'] }}@if(!$loop->last), @endif
@endforeach
</p>
<p class="mb-1"><span class="fw-bold">Creators:</span>
{{-- <p class="mb-1"><span class="fw-bold">Creators:</span>
@foreach($show['crew'] as $actor)
{{ $actor['name'] }}@if(!$loop->last), @endif
@endforeach
</p>
</p> --}}
@isset($show['genres'])
<p class="mb-1"><span class="fw-bold pe-2">Genres:</span>
@foreach($show['genres'] as $genre)
<a href="{{route('shows.genre', $genre['slug'])}}">{{ $genre['name'] }}</a>@if(!$loop->last), @endif
<span>{{ $genre['name'] }}</span>@if(!$loop->last), @endif
@endforeach
</p>
@endisset
@ -151,16 +349,7 @@
{{-- <section
class="container mx-auto mt-5 p-1 grid gap-1 md:gap-1.5 2xl:gap-2 mb-4 grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-6"
>
<h3 class="col-span-full mb-2 text-xl font-semibold text-nav">Similar Movies</h3>
@foreach ( $similar->data as $item ) @include('components.movie_loop')
@endforeach
</section> --}}
{{-- @include('components.modal', ['backdrop' => $backdrop, 'url_redirect_loading' => $url_redirect_loading, 'title' => $movie->title, 'poster_path' => $movie->poster_path]) --}}
{{-- @include('components.modal', ['backdrop' => $backdrop, 'url_redirect_loading' => $url_redirect_loading, 'title' => $show->title, 'poster_path' => $show->poster_path]) --}}
@endsection @section('footer')

View file

@ -33,4 +33,5 @@
Route::get('/movie/{id}/{slug}', [MovieController::class, 'index'])->name('movie');
Route::get('/series/{id}/{slug}', [ShowController::class, 'index'])->name('show');
Route::get('/series/{id}/{slug}/season/{season}', [ShowController::class, 'season'])->name('show.season');
Route::get('/search', [HomeController::class, 'search'])->name('search');