35 lines
1.3 KiB
PHP
35 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Ticketing\Event\Controllers;
|
|
|
|
use App\Domains\Core\Tenant\Models\Tenant;
|
|
use App\Domains\Ticketing\Event\Models\Event;
|
|
use App\Domains\Ticketing\Event\Requests\ListPublicEventsRequest;
|
|
use App\Domains\Ticketing\Event\Resources\PublicEventResource;
|
|
use App\Domains\Ticketing\Event\Services\PublicEventService;
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
|
|
|
class PublicEventController extends Controller
|
|
{
|
|
public function index(ListPublicEventsRequest $request, Tenant $tenant, PublicEventService $events): AnonymousResourceCollection
|
|
{
|
|
abort_unless($tenant->storefront_website_type_code === 'onticket_multi_event', 404);
|
|
|
|
$term = trim((string) $request->validated('q', ''));
|
|
return PublicEventResource::collection($events->list(
|
|
$tenant,
|
|
$term,
|
|
(int) $request->validated('page', 1),
|
|
$request->validated('category_id', null) === null ? null : (int) $request->validated('category_id'),
|
|
));
|
|
}
|
|
|
|
public function show(Tenant $tenant, Event $event, PublicEventService $events): PublicEventResource
|
|
{
|
|
abort_unless($tenant->storefront_website_type_code === 'onticket_multi_event', 404);
|
|
|
|
return PublicEventResource::make($events->find($tenant, $event));
|
|
}
|
|
}
|