currentSort = $currentSort ?? request('ob', 'posted_desc'); $this->baseUrl = $baseUrl ?? request()->url(); $this->queryParams = $queryParams ?? request()->except(['ob', 'page']); // Default sort options for releases $this->sortOptions = $options ?? [ 'posted_desc' => ['label' => 'Posted (Newest)', 'icon' => 'fa-calendar-alt'], 'posted_asc' => ['label' => 'Posted (Oldest)', 'icon' => 'fa-calendar-alt'], 'added_desc' => ['label' => 'Added (Newest)', 'icon' => 'fa-clock'], 'added_asc' => ['label' => 'Added (Oldest)', 'icon' => 'fa-clock'], 'name_asc' => ['label' => 'Name (A-Z)', 'icon' => 'fa-font'], 'name_desc' => ['label' => 'Name (Z-A)', 'icon' => 'fa-font'], 'size_desc' => ['label' => 'Size (Largest)', 'icon' => 'fa-hdd'], 'size_asc' => ['label' => 'Size (Smallest)', 'icon' => 'fa-hdd'], 'files_desc' => ['label' => 'Files (Most)', 'icon' => 'fa-file'], 'files_asc' => ['label' => 'Files (Least)', 'icon' => 'fa-file'], 'stats_desc' => ['label' => 'Grabs (Most)', 'icon' => 'fa-download'], 'stats_asc' => ['label' => 'Grabs (Least)', 'icon' => 'fa-download'], ]; // Pre-compute current label and icon $this->currentLabel = $this->sortOptions[$this->currentSort]['label'] ?? 'Posted (Newest)'; $this->currentIcon = $this->sortOptions[$this->currentSort]['icon'] ?? 'fa-calendar-alt'; // Pre-compute all sort URLs $this->sortUrls = []; foreach ($this->sortOptions as $sortKey => $sortData) { $params = array_merge($this->queryParams, ['ob' => $sortKey]); $this->sortUrls[$sortKey] = $this->baseUrl.'?'.http_build_query($params); } } /** * Get the view / contents that represent the component. */ public function render(): View|Closure|string { return view('components.sort-dropdown'); } }