ldc-lionor/app/Http/Requests/Bo/Certifications/StoreCertificationRequest.php
noah.lancien 8278419606 Phpstan
2024-09-06 08:30:55 +00:00

69 lines
1.6 KiB
PHP

<?php
namespace App\Http\Requests\Bo\Certifications;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
class StoreCertificationRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize()
{
return auth('backend')->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->merge([
'status' => $this->boolean('status')
]);
$this->mergePicture('sticker');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'name' => 'required|min:3|max:255',
'sticker_alt' => 'required|min:3|max:255',
'sticker_title' => 'required|min:3|max:255',
'status' => 'required|boolean',
];
return \array_merge(
$rules,
$this->pictureRules('sticker', 150, 150, 150, 150, true),
);
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes()
{
return [
'name' => trans('nom'),
'sticker' => trans('vignette'),
'sticker_alt' => trans('attribut alt de la vignette'),
'sticker_title' => trans('titre de la vignette'),
'status' => trans('état de publication'),
];
}
}