<x-layouts.app>
    @include('theme::partials.navigation')
    @php
        $query = \Modules\Vod\Models\Video::where('status', 1);
        if(auth()->check() and session()->has('vod_profile') and session()->get('vod_profile')->age_range !== null){
            $profile = session()->get('vod_profile');
            $age = (int) $profile->age_range;
            $query = $query->whereHas('ageRange', function($q) use($age) {
                return $q->where('value', '<', $age);
            });
        }
        if($this->modelPage->vod_type) {
            $query = $query->where('vod_type', $this->modelPage->vod_type);
        } else {
            $query = $query->whereIn('vod_type', [\Modules\Serial\Enums\VodType::SERIES,\Modules\Serial\Enums\VodType::MOVIE]);
        }
        if($this->modelPage->tags) {
            $query = $query->whereHas('tags', function ($query) {
                $query->whereIn('video_tags.id', $this->modelPage->tags);
            });
        }
        if($this->modelPage->collection) {
            $query = $query->where('video_collection_id', $this->modelPage->collection);
        }
        $items = $query->orderBy('published_at', 'desc')->paginate($this->perPage);
        $static_disk = \Rezahmady\SettingOperation\Setting::get('storage_disks.video_static_disk', 'public') ?? 'public';
        $url = ($static_disk == 'public') ? url('') : \Modules\StorageDriver\Models\Disk::where('name', $static_disk)->value('domain').'/';
    @endphp
    @if($modelPage->coverLandscape)
        @include('theme::partials.category_top_banner')
    @endif

    <div class="@if($modelPage->coverLandscape) xl:-mt-8 2xl:-mt-8 3xl:-mt-8 @else py-20 min-h-screen @endif">
        @if(!$modelPage->coverLandscape)
        <h1 class="text-black px-5 lg:px-10 mb-4 text-lg font-bold flex items-center gap-2">
            {{$modelPage->title}}
        </h1>
        @endif
        @include('theme::partials.video_grid')
    </div>

    @sortableWidgets($widgetInstance, $block)
    @sortableWidgets($footerInstance, 'footer')

</x-layouts.app>

{{-- Seo --}}
@section('meta_title')
    @php
        $title = $modelPage->meta_title ?? "تماشای آنلاین ".$modelPage->title;
        $title = $title." | ". theme_option('meta_title');
    @endphp
    {{$title}}
@endsection
@section('meta_description')
    @php
        $description = $modelPage->meta_description ?? $modelPage->description;
    @endphp
    {{$description}}
@endsection
