82 lines
2.5 KiB
PHP
82 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Ranges;
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Str;
|
|
|
|
class UpdateRangeRequest extends FormRequest
|
|
{
|
|
use HasPicture;
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return auth('backend')->check();
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'slug' => Str::slug(strip_tags($this->label))
|
|
]);
|
|
$this->mergePicture('picture');
|
|
$this->mergePicture('picture_banner');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
$rules = [
|
|
'label' => 'required|min:3|max:255',
|
|
'seo_title' => 'required|min:45|max:70',
|
|
'seo_description' => 'required|min:50|max:160',
|
|
'color' => 'required|color_rgba',
|
|
'picture_alt' => 'required|min:3|max:255',
|
|
'picture_title' => 'required|min:3|max:255',
|
|
'picture_banner_alt' => 'required|min:3|max:255',
|
|
'picture_banner_title' => 'required|min:3|max:255',
|
|
];
|
|
return \array_merge(
|
|
$rules,
|
|
$this->pictureRules('picture', true, 290, 232, 290, 232),
|
|
$this->pictureRules('picture_banner', true, 1440, 300, 1440, 300),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'label' => trans('label'),
|
|
'slug' => trans('slug'),
|
|
'seo_title' => trans('title') . ' seo',
|
|
'seo_description' => trans('description') . ' seo',
|
|
'color' => trans('couleur'),
|
|
'picture' => trans('Illustration'),
|
|
'picture_alt' => trans('attribut alt de l\'image'),
|
|
'picture_title' => trans('titre de l\'image'),
|
|
'picture_banner' => trans('bannière'),
|
|
'picture_banner_alt' => trans('attribut alt de la bannière'),
|
|
'picture_banner_title' => trans('titre de la bannière'),
|
|
];
|
|
}
|
|
}
|