Replace old download search with new patreon file search
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Hentai;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class Downloads extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
public $search;
|
||||
|
||||
public $order = 'az';
|
||||
|
||||
public $withTorrents;
|
||||
|
||||
protected $queryString = [
|
||||
'search' => ['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,
|
||||
]);
|
||||
}
|
||||
}
|
@@ -6,7 +6,7 @@ use App\Models\Downloads;
|
||||
use Livewire\Component;
|
||||
use Livewire\WithPagination;
|
||||
|
||||
class DownloadsPatreon extends Component
|
||||
class DownloadsSearch extends Component
|
||||
{
|
||||
use WithPagination;
|
||||
|
||||
@@ -72,12 +72,12 @@ class DownloadsPatreon extends Component
|
||||
}
|
||||
|
||||
$downloads = Downloads::when($this->fileSearch != '', fn ($query) => $query->where('url', 'like', '%'.$this->fileSearch.'%'))
|
||||
->where('size', '>', 0)
|
||||
->where(fn ($q) => $q->where('type', '=', 'UHD')->orWhere('type', '=', 'UHDi'))
|
||||
->when(!auth()->user()->is_patreon, fn ($query) => $query->whereIn('type', ['FHD', 'FHDi']))
|
||||
->whereNotNull('size')
|
||||
->orderBy($orderby, $orderdirection)
|
||||
->paginate(20);
|
||||
|
||||
return view('livewire.downloads-patreon', [
|
||||
return view('livewire.downloads-search', [
|
||||
'downloads' => $downloads,
|
||||
'query' => $this->fileSearch,
|
||||
]);
|
Reference in New Issue
Block a user