<?php

namespace App\Http\Requests\Admin\Finance;

use App\Concerns\CurrencyStripping;
use Illuminate\Foundation\Http\FormRequest;
use Override;

class EmployeeAdvancePaymentRequest extends FormRequest
{
    use CurrencyStripping;

    public function authorize(): bool
    {
        return $this->user()->can('employee_advances.pay');
    }

    #[Override]
    public function prepareForValidation(): void
    {
        $this->merge($this->stripCurrencyDot($this->all(), 'amount'));
    }

    public function rules(): array
    {
        return [
            'amount' => ['required', 'integer', 'min:1'],
        ];
    }

    public function attributes(): array
    {
        return [
            'amount' => 'jumlah bayar',
        ];
    }
}
