52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\CreditAccounts;
|
|
|
|
use App\Enums\Credit\AccountTypeEnum;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class StoreCreditAccountRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::allows('isAdmin');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'label' => 'required|string|min:3|max:255',
|
|
'type' => [
|
|
'required',
|
|
Rule::in(collect(AccountTypeEnum::cases())->pluck('value')->all()),
|
|
],
|
|
'balance' => 'required|numeric|min:0|max:255',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'label' => trans('Label du compte'),
|
|
'type' => trans('Type du compte'),
|
|
'balance' => trans('Solde du compte'),
|
|
];
|
|
}
|
|
}
|