ldc-lionor/app/Http/Requests/Bo/Certifications/StoreCertificationRequest.php

70 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2023-02-24 15:20:58 +00:00
<?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([
2024-09-06 08:30:55 +00:00
'status' => $this->boolean('status')
2023-02-24 15:20:58 +00:00
]);
$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),
2023-02-24 15:20:58 +00:00
);
}
/**
* 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'),
];
}
}