feat(events): add event categories and filtering

This commit is contained in:
2026-09-21 09:16:28 -03:00
parent b0702b7e15
commit 79d402e210
13 changed files with 134 additions and 8 deletions

View File

@@ -8,12 +8,17 @@ use Illuminate\Contracts\Pagination\LengthAwarePaginator;
class PublicEventService
{
public function list(Tenant $tenant, string $term, int $page): LengthAwarePaginator
public function list(Tenant $tenant, string $term, int $page, ?int $categoryId = null): LengthAwarePaginator
{
$query = $tenant->events()
->whereNotNull('published_at')
->where('published_at', '<=', now());
if ($categoryId !== null) {
abort_unless($tenant->eventCategories()->whereKey($categoryId)->exists(), 404);
$query->where('event_category_id', $categoryId);
}
if ($term !== '') {
$query->where(function ($query) use ($term): void {
$query->where('title', 'like', '%'.$term.'%')