forked from eatvio/eatvio-infra
43 lines
944 B
PHP
43 lines
944 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Recipe;
|
|
|
|
use App\Models\User;
|
|
use App\Services\Recipe\ListViewService;
|
|
use Illuminate\View\View;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
|
|
class ListView extends Component
|
|
{
|
|
use WithPagination;
|
|
|
|
public string $search = '';
|
|
|
|
public string $typeFilter = 'all';
|
|
|
|
public string $tag = '';
|
|
|
|
public User|null $author = null;
|
|
|
|
protected array $queryString = [
|
|
'search' => ['except' => ''],
|
|
'typeFilter' => ['except' => 'all'],
|
|
'tag' => ['except' => ''],
|
|
'author' => ['except' => ''],
|
|
];
|
|
|
|
public function render(ListViewService $service): View
|
|
{
|
|
$recipes = $service->buildRecipes();
|
|
|
|
return view(
|
|
'livewire.recipe.list-view',
|
|
[
|
|
'recipes' => $recipes->orderByDesc('updated_at')->paginate(10),
|
|
'rawTypes' => $service->getTagsCollection(),
|
|
]
|
|
);
|
|
}
|
|
}
|