['except' => '', 'as' => 's'], 'withTorrents' => ['withTorrents' => '', 'as' => 'withTorrents'], 'order' => ['except' => '', 'as' => 'order'], ]; public function updatingSearch() { $this->resetPage(); } public function render() { $orderby = 'slug'; $orderdirection = 'desc'; switch ($this->order) { case 'az': $orderby = 'slug'; $orderdirection = 'asc'; break; case 'za': $orderby = 'slug'; $orderdirection = 'desc'; break; default: $orderby = 'created_at'; $orderdirection = 'desc'; } $hentai = Hentai::with('episodes') ->when($this->search != '', fn ($query) => $query->whereHas('episodes', fn ($q) => $q->where('title', 'like', '%'.$this->search.'%')->orWhere('title_jpn', 'like', '%'.$this->search.'%'))) ->when($this->withTorrents != '', fn ($query) => $query->whereHas('torrents')) ->orderBy($orderby, $orderdirection) ->paginate(10); return view('livewire.downloads', [ 'hentai' => $hentai, 'query' => $this->search, ]); } }