From b9f412bccbb0627b58caacb36de5d1d30dd2a349 Mon Sep 17 00:00:00 2001 From: fabiorodriguesroque Date: Wed, 13 Nov 2024 19:36:08 +0000 Subject: [PATCH] refactor: add return types and type some properties --- app/Livewire/Project/Items.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/Livewire/Project/Items.php b/app/Livewire/Project/Items.php index 7f343aff..62fff3c0 100644 --- a/app/Livewire/Project/Items.php +++ b/app/Livewire/Project/Items.php @@ -2,22 +2,29 @@ namespace App\Livewire\Project; +use App\Models\Item; use App\Models\Board; use App\Models\Project; use Livewire\Component; +use Illuminate\Support\Collection; +use Illuminate\Contracts\View\View; class Items extends Component { public Project $project; public Board $board; - public $items = []; + /** @var Collection */ + public Collection $items; + /** + * @var string[] + */ protected $listeners = [ 'item-created' => '$refresh', ]; - public function render() + public function render(): View { $this->items = $this->board->items() ->visibleForCurrentUser() @@ -30,11 +37,11 @@ public function render() return view('livewire.board.items'); } - protected function getSortingColumn() + protected function getSortingColumn(): string { return match ($this->board->sort_items_by) { 'popular' => 'total_votes', - 'latest' => 'created_at', + default => 'created_at', }; } }