Reapply "Merge pull request #3380 from Roardom/livewire-types"

This reverts commit b4a9dfea8b.
This commit is contained in:
Roardom
2024-01-24 08:03:05 +00:00
parent 12091abdcc
commit fe31076104
52 changed files with 626 additions and 1063 deletions
+12 -12
View File
@@ -15,11 +15,13 @@ namespace App\Http\Livewire;
use App\Models\History;
use App\Models\User;
use App\Traits\LivewireSort;
use Livewire\Component;
use Livewire\WithPagination;
class UserTorrents extends Component
{
use LivewireSort;
use WithPagination;
public ?User $user = null;
@@ -44,14 +46,20 @@ class UserTorrents extends Component
public string $downloaded = 'any';
/**
* @var string[]
*/
public array $status = [];
public string $sortField = 'created_at';
public string $sortDirection = 'desc';
public $showMorePrecision = false;
public bool $showMorePrecision = false;
/**
* @var array<mixed>
*/
protected $queryString = [
'perPage' => ['except' => ''],
'name' => ['except' => ''],
@@ -84,6 +92,9 @@ class UserTorrents extends Component
$this->resetPage();
}
/**
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<History>
*/
final public function getHistoryProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
{
return History::query()
@@ -169,15 +180,4 @@ class UserTorrents extends Component
'histories' => $this->history,
]);
}
final public function sortBy($field): void
{
if ($this->sortField === $field) {
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
} else {
$this->sortDirection = 'asc';
}
$this->sortField = $field;
}
}