77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests\Bo\Sliders;
|
||
|
|
|
||
|
|
use App\Enums\Sliders\SliderPosition;
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
|
||
|
|
|
||
|
|
class StoreSliderRequest extends FormRequest
|
||
|
|
{
|
||
|
|
/**
|
||
|
|
* 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->merge([
|
||
|
|
'link_new_tab' => $this->link_new_tab ? true : false,
|
||
|
|
'status' => $this->status ? true : false
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get the validation rules that apply to the request.
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function rules()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'title' => 'required|min:3|max:255',
|
||
|
|
'title_color' => 'required|color_hex',
|
||
|
|
'title_color_bg' => 'required|color_hex',
|
||
|
|
'position' => ['required', new EnumIsValidRule(SliderPosition::class)],
|
||
|
|
'picture' => 'required|image|dimensions:width=1400,height=630|mimes:png,jpg,jpeg,gif',
|
||
|
|
'link' => 'required|url',
|
||
|
|
'link_title' => 'required|min:3|max:255',
|
||
|
|
'link_color' => 'required|color_hex',
|
||
|
|
'link_color_bg' => 'required|color_hex',
|
||
|
|
'link_new_tab' => 'required|boolean',
|
||
|
|
'status' => 'required|boolean'
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Get custom attributes for validator errors.
|
||
|
|
*
|
||
|
|
* @return array
|
||
|
|
*/
|
||
|
|
public function attributes(): array
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'title' => trans('title'),
|
||
|
|
'title_color' => trans('couleur de titre'),
|
||
|
|
'title_color_bg' => trans('couleur de fond du titre'),
|
||
|
|
'position' => trans('position de centrage de l\'image'),
|
||
|
|
'link' => trans('lien'),
|
||
|
|
'link_title' => trans('titre du lien'),
|
||
|
|
'link_color' => trans('couleur du lien'),
|
||
|
|
'link_color_bg' => trans('couleur de fond du lien'),
|
||
|
|
'link_new_tab' => trans('nouvel onglet'),
|
||
|
|
'status' => trans('publication'),
|
||
|
|
];
|
||
|
|
}
|
||
|
|
}
|