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
+8 -11
View File
@@ -15,6 +15,7 @@ namespace App\Http\Livewire;
use App\Models\BonTransactions;
use App\Models\User;
use App\Traits\LivewireSort;
use Livewire\Component;
use Livewire\WithPagination;
@@ -23,6 +24,7 @@ use Livewire\WithPagination;
*/
class GiftLogSearch extends Component
{
use LivewireSort;
use WithPagination;
public string $sender = '';
@@ -37,6 +39,9 @@ class GiftLogSearch extends Component
public int $perPage = 25;
/**
* @var array<mixed>
*/
protected $queryString = [
'sender' => ['except' => ''],
'receiver' => ['except' => ''],
@@ -49,6 +54,9 @@ class GiftLogSearch extends Component
$this->emit('paginationChanged');
}
/**
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator<BonTransactions>
*/
final public function getGiftsProperty(): \Illuminate\Contracts\Pagination\LengthAwarePaginator
{
return BonTransactions::with([
@@ -69,15 +77,4 @@ class GiftLogSearch extends Component
'gifts' => $this->gifts,
]);
}
final public function sortBy($field): void
{
if ($this->sortField === $field) {
$this->sortDirection = $this->sortDirection === 'asc' ? 'desc' : 'asc';
} else {
$this->sortDirection = 'asc';
}
$this->sortField = $field;
}
}