2023-08-14 09:23:39 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Packages;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
|
|
|
|
|
|
class StorePackageRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize()
|
|
|
|
|
{
|
|
|
|
|
return Gate::allows('isAdmin');
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-26 10:20:22 +01:00
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function prepareForValidation(): void
|
|
|
|
|
{
|
|
|
|
|
$this->merge([
|
|
|
|
|
'published' => $this->boolean('published'),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-14 09:23:39 +00:00
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules()
|
|
|
|
|
{
|
|
|
|
|
return [
|
2023-08-17 16:52:17 +02:00
|
|
|
'name' => 'required|string|min:3|max:255',
|
|
|
|
|
'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/',
|
2026-02-26 10:20:22 +01:00
|
|
|
'published' => 'required|boolean',
|
2023-08-14 09:23:39 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'name' => trans('Nom'),
|
|
|
|
|
'amount' => trans('Montant (par jour)'),
|
2026-02-26 10:20:22 +01:00
|
|
|
'published' => trans('Publication')
|
2023-08-14 09:23:39 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|