feat(staff): scope scanner management and category assignments by event
This commit is contained in:
@@ -10,7 +10,7 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
class StaffFormService
|
||||
{
|
||||
/** @return array{categories: Collection<int, Category>} */
|
||||
public function get(Tenant $tenant): array
|
||||
public function get(Tenant $tenant, ?int $eventId = null): array
|
||||
{
|
||||
return [
|
||||
'categories' => Category::query()
|
||||
@@ -20,6 +20,8 @@ class StaffFormService
|
||||
->orWhereHas('catalogItems', fn (Builder $items) => $items
|
||||
->where('tenant_code', $tenant->codigo));
|
||||
})
|
||||
->when($eventId !== null, fn (Builder $query) => $query->whereHas(
|
||||
'catalogItems', fn (Builder $items) => $items->where('tenant_code', $tenant->codigo)->where('event_id', $eventId)))
|
||||
->orderBy('nombre')
|
||||
->get(),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user