2024-04-12 13:41:57 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Ranges;
|
|
|
|
|
|
|
|
|
|
use App\Models\Range;
|
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
|
use LVR\Colour\Hex;
|
|
|
|
|
|
|
|
|
|
class StoreRangeRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
use HasPicture;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return Gate::check('create', Range::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
protected function prepareForValidation(): void
|
|
|
|
|
{
|
|
|
|
|
$this->merge([
|
|
|
|
|
'published' => $this->boolean('published'),
|
|
|
|
|
]);
|
|
|
|
|
$this->mergePicture('banner');
|
|
|
|
|
$this->mergePicture('banner_ambiance');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
$rules = [
|
|
|
|
|
'label' => 'required|string|between:3,255',
|
|
|
|
|
'description' => 'required|string|min:3',
|
|
|
|
|
'banner_alt' => 'required|string|between:3,255',
|
|
|
|
|
'banner_title' => 'required|string|between:3,255',
|
|
|
|
|
'banner_ambiance_alt' => 'required|string|between:3,255',
|
|
|
|
|
'banner_ambiance_title' => 'required|string|between:3,255',
|
|
|
|
|
'color' => ['required', new Hex()],
|
|
|
|
|
'published' => 'required|boolean',
|
|
|
|
|
];
|
|
|
|
|
return \array_merge(
|
|
|
|
|
$rules,
|
|
|
|
|
$this->pictureRules('banner', 700, 350, 700, 350, false),
|
|
|
|
|
$this->pictureRules('banner_ambiance', 1440, 420, 1440, 420, false),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2024-04-16 10:32:26 +02:00
|
|
|
'label' => trans('validation.custom.label'),
|
|
|
|
|
'description' => trans('validation.attributes.description'),
|
|
|
|
|
'banner_alt' => trans(':field :inter:field2', [
|
2024-04-19 10:08:36 +02:00
|
|
|
'field' => __('validation.custom.attribute_alt'),
|
2024-04-16 10:32:26 +02:00
|
|
|
'inter' => __('validation.custom.of_the.female'),
|
|
|
|
|
'field2' => __('validation.custom.banner'),
|
|
|
|
|
]),
|
|
|
|
|
'banner_title' => trans(':field :inter:field2', [
|
2024-04-19 10:08:36 +02:00
|
|
|
'field' => __('validation.custom.attribute_title'),
|
2024-04-16 10:32:26 +02:00
|
|
|
'inter' => __('validation.custom.of_the.female'),
|
|
|
|
|
'field2' => __('validation.custom.banner'),
|
|
|
|
|
]),
|
|
|
|
|
'banner_ambiance_alt' => trans(':field :inter:field2', [
|
2024-04-19 10:08:36 +02:00
|
|
|
'field' => __('validation.custom.attribute_alt'),
|
2024-04-16 10:32:26 +02:00
|
|
|
'inter' => __('validation.custom.of_the.female'),
|
|
|
|
|
'field2' => __('validation.custom.banner_ambiance'),
|
|
|
|
|
]),
|
|
|
|
|
'banner_ambiance_title' => trans(':field :inter:field2', [
|
2024-04-19 10:08:36 +02:00
|
|
|
'field' => __('validation.custom.attribute_title'),
|
2024-04-16 10:32:26 +02:00
|
|
|
'inter' => __('validation.custom.of_the.female'),
|
|
|
|
|
'field2' => __('validation.custom.banner_ambiance'),
|
|
|
|
|
]),
|
|
|
|
|
'color' => trans('validation.custom.color'),
|
|
|
|
|
'published' => trans('validation.custom.publication')
|
2024-04-12 13:41:57 +00:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|