@extends('layouts.app') @section('title', isset($query) ? 'Search: ' . $query . ' | ' . config('app.name') : config('app.name')) @section('extra_styles') @endsection @section('content') {{-- ── Filter chip bar ── --}} @unless(isset($query)) @php $activeFilter = request('filter', 'all'); @endphp
{{-- /yt-filter-bar-wrap --}} @endunless
{{-- ══════════════════════════════════════════════ SEARCH RESULTS ══════════════════════════════════════════════ --}} @isset($query) @php $searchShorts = $shorts ?? collect(); $searchPlaylists = $playlists ?? collect(); $searchChannels = $channels ?? collect(); $totalResults = $videos->count() + $searchShorts->count() + $searchPlaylists->count() + $searchChannels->count(); @endphp

Search results for "{{ $query }}"

@if($videos->count()) {{ $videos->count() }} video{{ $videos->count() !== 1 ? 's' : '' }} @endif @if($searchShorts->count())  ·  {{ $searchShorts->count() }} short{{ $searchShorts->count() !== 1 ? 's' : '' }} @endif @if($searchChannels->count())  ·  {{ $searchChannels->count() }} channel{{ $searchChannels->count() !== 1 ? 's' : '' }} @endif @if($searchPlaylists->count())  ·  {{ $searchPlaylists->count() }} playlist{{ $searchPlaylists->count() !== 1 ? 's' : '' }} @endif @if($totalResults === 0) No results found @endif

@if($searchChannels->count())
Channels
@foreach($searchChannels as $channel) @if($channel->avatar_url) {{ $channel->name }} @else
@endif
{{ $channel->name }}
@if($channel->username)
@{{ $channel->username }}
@endif
@endforeach
@endif @if($videos->count())
Videos
@foreach($videos as $video) @include('components.video-card', ['video' => $video]) @endforeach
@endif @if($searchShorts->count())
Shorts
@foreach($searchShorts as $video) @include('components.video-card', ['video' => $video]) @endforeach
@endif @if($searchPlaylists->count())
Playlists
@foreach($searchPlaylists as $pl) @include('components.playlist-card', ['playlist' => $pl]) @endforeach
@endif @if($totalResults === 0)

No results for "{{ $query }}"

Try different keywords or browse the gallery.

@endif @endisset {{-- ══════════════════════════════════════════════ PLAYLISTS-ONLY FILTER ══════════════════════════════════════════════ --}} @if(!isset($query) && isset($filter) && $filter === 'playlists') @if(isset($playlists) && $playlists->count())
@foreach($playlists as $pl) @include('components.playlist-card', ['playlist' => $pl]) @endforeach
@else

No public playlists yet

@endif {{-- ══════════════════════════════════════════════ HOME — MIXED FEED ══════════════════════════════════════════════ --}} @elseif(!isset($query) && (!isset($filter) || $filter === 'all')) @if(isset($feedItems) && $feedItems->count())
@foreach($feedItems as $entry) @if($entry['kind'] === 'video') @include('components.video-card', ['video' => $entry['item']]) @else @php $pl = $entry['item']; @endphp @include('components.playlist-card', ['playlist' => $pl]) @endif @endforeach
@else

No content yet

@auth Upload First Video @endauth
@endif {{-- ══════════════════════════════════════════════ SINGLE-TYPE FILTERED VIEWS ══════════════════════════════════════════════ --}} @elseif(!isset($query)) @if($videos->isEmpty())

Nothing here yet

@else
@foreach($videos as $video) @include('components.video-card', ['video' => $video]) @endforeach
@endif @endif {{-- Infinite-scroll sentinel. The IntersectionObserver down in @section('scripts') fetches the next cursor page when this comes into view and appends the rendered cards to the grid above. A visible "Load more" button is the always-available fallback. --}}
{{-- /filter-content --}} @endsection @section('scripts') @endsection