79 lines
1.9 KiB
PHP
79 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Engagements;
|
|
|
|
use App\Http\Requests\Bo\UpdateMiniCrudRequest;
|
|
use App\Traits\Requests\HasPicture;
|
|
use Illuminate\Support\Str;
|
|
|
|
class UpdateEngagementsRequest extends UpdateMiniCrudRequest
|
|
{
|
|
use HasPicture;
|
|
|
|
/**
|
|
* The model parameter name
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $modelName = 'engagement';
|
|
|
|
/**
|
|
* 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()
|
|
{
|
|
$this->merge([
|
|
'slug' => Str::slug($this->name)
|
|
]);
|
|
$this->mergePicture('banner');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return array_merge(
|
|
[
|
|
'title' => 'required|min:3|max:255',
|
|
'seo_title' => 'required|min:53|max:60',
|
|
'seo_description' => 'required|min:50|max:160',
|
|
'banner_alt' => 'required_with:banner|nullable|string|min:6|max:255',
|
|
'banner_title' => 'required_with:banner|nullable|string|min:6|max:255'
|
|
],
|
|
self::pictureRules('banner', 1920, 340, 1920, 340),
|
|
parent::rules()
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'title' => trans('title'),
|
|
'seo_title' => trans('title') . ' seo',
|
|
'seo_description' => trans('description') . ' seo',
|
|
'banner' => trans('bannière'),
|
|
'banner_alt' => trans('Texte alternatif de la bannière'),
|
|
'banner_title' => trans('Titre de la bannière')
|
|
];
|
|
}
|
|
}
|