97 lines
3 KiB
PHP
97 lines
3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Homes;
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateHomeRequest 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->mergePicture('part3_picture');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
$rules = [
|
|
'seo_title' => 'required|min:3|max:70',
|
|
'seo_description' => 'required|min:50|max:160',
|
|
|
|
'part1_title' => 'required|min:3|max:70',
|
|
'part1_subtitle' => 'required|min:3|max:70',
|
|
'part1_text_1' => 'required|string|min:15',
|
|
'part1_text_2' => 'required|string|min:15',
|
|
'part1_text_3' => 'required|string|min:15',
|
|
|
|
'part2_title' => 'required|min:3|max:70',
|
|
'part2_subtitle' => 'required|min:3|max:70',
|
|
'part2_text' => 'required|string|min:15',
|
|
'part2_list' => 'present|array',
|
|
'part2_list.*' => 'required|array',
|
|
'part2_list.*.value' => 'required|string|min:3|max:255',
|
|
'part2_product1_id' => 'required|exists:products,id',
|
|
'part2_product2_id' => 'required|exists:products,id',
|
|
|
|
'part3_picture_alt' => 'required|min:3|max:255',
|
|
'part3_picture_title' => 'required|min:3|max:255',
|
|
];
|
|
return \array_merge(
|
|
$rules,
|
|
$this->pictureRules('part3_picture', true, 2048, 1366, 2048, 1366),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes()
|
|
{
|
|
return [
|
|
'seo_title' => trans('titre') . ' seo',
|
|
'seo_description' => trans('description') . ' seo',
|
|
|
|
'part1_title' => trans('title part.1'),
|
|
'part1_subtitle' => trans('subtitle part.1'),
|
|
'part1_text_1' => trans('text 1 part.1'),
|
|
'part1_text_2' => trans('text 2 part.1'),
|
|
'part1_text_3' => trans('text 3 part.1'),
|
|
|
|
'part2_title' => trans('title part.2'),
|
|
'part2_subtitle' => trans('subtitle part.2'),
|
|
'part2_text' => trans('text part.2'),
|
|
'part2_list' => trans('values of the list part.2'),
|
|
'part2_list.*.value' => trans('value of the list part.2'),
|
|
'part2_product1_id' => trans('value of the first product part.2'),
|
|
'part2_product2_id' => trans('value of the second product part.2'),
|
|
|
|
'part3_picture' => trans('illustration'),
|
|
'part3_picture_alt' => trans('alt attribute of the image'),
|
|
'part3_picture_title' => trans('title attribute of the image'),
|
|
];
|
|
}
|
|
}
|