This commit is contained in:
2025-09-18 15:31:27 +02:00
commit 2abba0c2b7
406 changed files with 31879 additions and 0 deletions

View File

@@ -0,0 +1,60 @@
<?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,
]);
}
}