<?php

namespace Modules\User\Http\Controllers;

use App\Http\Controllers\BaseCrudController;
use Illuminate\Http\JsonResponse;
use Modules\User\Entities\Employment;
use Modules\User\Http\Requests\EmploymentRequest;
use Modules\User\Repositories\Contracts\EmploymentRepositoryInterface;
use Modules\User\Transformers\EmploymentResource;

class EmploymentController extends BaseCrudController
{
    protected $modelClass = Employment::class;

    protected $resourceClass = EmploymentResource::class;

    protected $requestClass = EmploymentRequest::class;

    protected $resourceName = 'employment';

    protected $resourceNamePlural = 'employments';

    public function __construct(
        EmploymentRepositoryInterface $employmentRepository,
    ) {
        parent::__construct($employmentRepository);
    }

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

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

    protected function prepareUpdateData(array $validated, $employment): array
    {
        return $validated;
    }

    protected function checkDependencies($employment): ?JsonResponse
    {
        return null;
    }
}