75 lines
2.2 KiB
PHP
75 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Homepage;
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateHomepageRequest 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()
|
|
{
|
|
$this->mergePicture('picture');
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules()
|
|
{
|
|
$rules = [
|
|
'title_part1' => 'required|string|between:3,255',
|
|
'title_part2' => 'required|string|between:3,255',
|
|
'title_part3' => 'required|string|between:3,255',
|
|
'picture_alt' => 'required|string|between:3,255',
|
|
'picture_title' => 'required|string|between:3,255',
|
|
'presentation_title' => 'required|string|between:3,255',
|
|
'presentation_content' => 'required|string',
|
|
];
|
|
return \array_merge(
|
|
$rules,
|
|
$this->pictureRules('picture', 640, 390, 640, 390, false),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'title_part1' => trans('validation.custom.title_part1'),
|
|
'title_part2' => trans('validation.custom.title_part2'),
|
|
'title_part3' => trans('validation.custom.title_part3'),
|
|
'picture_alt' => trans('validation.custom.picture_alt', [
|
|
'field' => __('validation.custom.picture')
|
|
]),
|
|
'picture_title' => trans('validation.custom.picture_title', [
|
|
'field' => __('validation.custom.picture')
|
|
]),
|
|
'presentation_title' => trans('validation.custom.presentation_title'),
|
|
'presentation_content' => trans('validation.custom.presentation_content'),
|
|
];
|
|
}
|
|
}
|