<?php

namespace App\Domains\Event\Controllers\AdminApp;

use App\Domains\Event\Requests\UpdateEventRequest;
use App\Domains\Event\Resources\EventResource;
use App\Domains\Event\Services\EventService;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;

class EventController extends Controller
{
    public function __construct(protected EventService $eventService) {}

    public function show(Request $request): EventResource
    {
        return EventResource::make(
            $this->eventService->forTenant($request->user()->tenant()->firstOrFail())
        );
    }

    public function update(UpdateEventRequest $request): EventResource
    {
        return EventResource::make(
            $this->eventService->updateForTenant(
                $request->user()->tenant()->firstOrFail(),
                $request->validated()
            )
        );
    }
}
