ldc-supportweb/app/Http/Requests/Bo/CreditLogs/StoreCreditLogRequest.php
2025-04-23 12:24:31 +02:00

50 lines
1.2 KiB
PHP

<?php
namespace App\Http\Requests\Bo\CreditLogs;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class StoreCreditLogRequest 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 [
'amount' => [
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed
'required', 'numeric', 'min:0', 'max:255', function ($attribute, $value, $fail) {
if (($value * 10) % 5 !== 0) {
$fail("Le Montant de l'opération doit être divisible par 0.5 jour/homme");
}
},
],
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'amount' => trans('Montant de l\'opération'),
];
}
}