70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Bo\Subranges;
|
|
|
|
use App\Models\Subrange;
|
|
use App\Traits\Requests\HasPicture;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use LVR\Colour\Hex;
|
|
|
|
class StoreSubrangeRequest extends FormRequest
|
|
{
|
|
use HasPicture;
|
|
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return Gate::check('create', Subrange::class);
|
|
}
|
|
|
|
/**
|
|
* Prepare the data for validation.
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$this->merge([
|
|
'published' => $this->boolean('published'),
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'label' => 'required|string|between:3,255',
|
|
'description' => 'required|string|min:3',
|
|
'range_id' => 'required|exists:ranges,id',
|
|
'published' => 'required|boolean',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'title' => trans('validation.attributes.title'),
|
|
'sustitle' => trans('validation.custom.sustitle'),
|
|
'picto' => trans('validation.custom.picto'),
|
|
'picto_alt' => trans('validation.custom.alt_attribute'),
|
|
'picto_title' => trans('validation.custom.title_attribute'),
|
|
'text' => trans('validation.attributes.text'),
|
|
'is_large' => trans('validation.custom.is_large'),
|
|
'published' => trans('validation.custom.publication')
|
|
];
|
|
}
|
|
}
|