<?php

namespace App\Http\Requests\Admin\Finance;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class CashAccountRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user()->can('cash.update');
    }

    public function rules(): array
    {
        $cashAccount = $this->route('cash_account');

        return [
            'name' => ['required', 'string', 'max:200', Rule::unique('cash_accounts', 'name')->ignore($cashAccount)],
        ];
    }

    public function attributes(): array
    {
        return [
            'name' => 'nama',
        ];
    }
}
