<?php

namespace Modules\Activity\Http\Controllers;

use App\Http\Controllers\BaseCrudController;
use Modules\Activity\Entities\ActivityReport;
use Modules\Activity\Http\Requests\ActivityReportRequest;
use Modules\Activity\Repositories\Contracts\ActivityReportRepositoryInterface;
use Modules\Activity\Transformers\ActivityReportResource;

class ActivityReportController extends BaseCrudController
{
    protected $modelClass = ActivityReport::class;

    protected $resourceClass = ActivityReportResource::class;

    protected $requestClass = ActivityReportRequest::class;

    protected $resourceName = 'activity report';

    protected $resourceNamePlural = 'activity reports';

    public function __construct(
        ActivityReportRepositoryInterface $repository,
    ) {
        parent::__construct($repository);
    }

    protected function prepareStoreData(array $validated): array
    {
        return array_merge($validated, [
            'prepared_by' => auth()->id(),
        ]);
    }

    protected function getItemName($item): string
    {
        return $item->activity?->title ?? $item->id;
    }
}
