Skip to content

Commit

Permalink
refactor: add return types and type some properties
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiorodriguesroque committed Nov 13, 2024
1 parent c44683a commit b9f412b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/Livewire/Project/Items.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, Item> */
public Collection $items;

/**
* @var string[]
*/
protected $listeners = [
'item-created' => '$refresh',
];

public function render()
public function render(): View
{
$this->items = $this->board->items()
->visibleForCurrentUser()
Expand All @@ -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',
};
}
}

0 comments on commit b9f412b

Please sign in to comment.