ldc-legaulois/app/Http/Requests/Bo/MenuNodeData/UpdateMenuNodeDataRequest.php

69 lines
2.1 KiB
PHP
Raw Normal View History

2024-04-12 10:18:11 +02:00
<?php
namespace App\Http\Requests\Bo\MenuNodeData;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class UpdateMenuNodeDataRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return Gate::check('update', $this->route('menu_node_data'));
}
/**
* Prepare the data for validation.
*
* @return void
*/
public function prepareForValidation(): void
{
$this->merge([
'text' => str($this->input('text'))->value(),
'link_target' => $this->boolean('link_target'),
'link_status' => $this->boolean('link_status'),
'picture_status' => $this->boolean('picture_status'),
]);
$this->mergePicture('picture');
$this->mergePicture('background_picture');
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string,\Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$rules = [
'title' => 'required|string|min:4|max:255',
'text' => 'present|string|max:255',
'link_url' => 'string|max:255',
'link_title' => 'required|string|between:3,255',
'link_target' => 'required|boolean',
'link_status' => 'string|boolean',
'picture' => 'string|max:255',
'picture_alt' => 'string|between:3,255',
'picture_title' => 'string|between:3,255',
'picture_status' => 'string|boolean',
'background_picture' => 'string|max:255',
'background_picture_alt' => 'string|between:3,255',
'background_picture_title' => 'string|between:3,255',
];
return \array_merge(
$rules,
$this->pictureRules('picture', 180, 228, 180, 228),
$this->pictureRules('background_picture', 500, 231, 500, 231),
);
}
}