<?php

namespace Modules\User\Http\Controllers;

use App\Http\Controllers\BaseCrudController;
use Illuminate\Http\JsonResponse;
use Modules\User\Entities\BankDetail;
use Modules\User\Http\Requests\BankDetailRequest;
use Modules\User\Repositories\Contracts\BankDetailRepositoryInterface;
use Modules\User\Transformers\BankDetailResource;

class BankDetailController extends BaseCrudController
{
    protected $modelClass = BankDetail::class;

    protected $resourceClass = BankDetailResource::class;

    protected $requestClass = BankDetailRequest::class;

    protected $resourceName = 'bank_detail';

    protected $resourceNamePlural = 'bank_details';

    public function __construct(
        BankDetailRepositoryInterface $bankDetailRepository,
    ) {
        parent::__construct($bankDetailRepository);
    }

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

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

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

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