ldc-legaulois/app/Http/Requests/UpdateNutritionPageRequest.php

56 lines
1.4 KiB
PHP

<?php
namespace App\Http\Requests;
class UpdateNutritionPageRequest extends UpdateMiniAcfRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
if (auth()->check()) {
$this->merge([
'status' => $this->status === null ? 0 : 1
]);
return true;
}
return false;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$rules = [
'menutitle' => 'required|string|min:7|max:50',
'title' => 'required|string|min:7|max:255',
'metaTitle' => 'required|string|min:20|max:60',
'metaDescription' => 'required|string|min:130|max:160',
'headerContent' => 'required|string|min:10'
];
return array_merge(
$rules,
$this->genRules($this->nutrition_page->content)
);
}
public function attributes()
{
return \array_merge(
[
'menutitle' => \trans('Titre menu'),
'title' => \trans('Titre'),
'metaTitle' => \trans('Titre'),
'metaDescription' => \trans('Description meta'),
'headerContent' => \trans('Contenu entête')
],
parent::attributes()
);
}
}