forked from eatvio/eatvio-infra
41 lines
903 B
PHP
41 lines
903 B
PHP
<?php
|
|
|
|
namespace App\Livewire\BlogPost;
|
|
|
|
use App\Models\BlogPost;
|
|
use App\Models\Tag;
|
|
use App\Models\User;
|
|
use Illuminate\Support\Str;
|
|
use Illuminate\View\View;
|
|
use Livewire\Component;
|
|
use Livewire\WithPagination;
|
|
use App\Services\BlogPost\ListViewService;
|
|
|
|
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
|
|
{
|
|
$posts = $service->buildBlogPosts();
|
|
|
|
return view('livewire.blog-post.list-view', ['blogPosts' => $posts->orderBy('created_at', 'desc')->paginate(10)]);
|
|
}
|
|
|
|
}
|