2026-02-24 11:43:07 +01:00
|
|
|
<?php
|
|
|
|
|
|
2026-03-02 16:06:37 +01:00
|
|
|
namespace App\Http\Requests\Bo\SectionApproaches;
|
2026-02-24 11:43:07 +01:00
|
|
|
|
|
|
|
|
use App\Models\SectionApproach;
|
|
|
|
|
use App\Rules\WysiwygLength;
|
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
|
|
|
|
|
|
class SectionApproachRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
use HasPicture;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return Gate::check('create', SectionApproach::class);
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-25 16:25:31 +02:00
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*/
|
2026-02-24 11:43:07 +01:00
|
|
|
protected function prepareForValidation(): void
|
|
|
|
|
{
|
|
|
|
|
$this->mergePicture('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|between:3,255',
|
2026-09-25 16:25:31 +02:00
|
|
|
'content' => ['required', 'string', new WysiwygLength()],
|
2026-02-24 11:43:07 +01:00
|
|
|
'picture_alt' => 'required_with:picture|nullable|between:3,255',
|
|
|
|
|
'picture_title' => 'required_with:picture|nullable|between:3,255',
|
2026-03-31 11:49:27 +02:00
|
|
|
'category_id' => 'required|exists:category_approaches,id',
|
2026-09-25 16:25:31 +02:00
|
|
|
'page_id' => 'required|exists:static_pages,id',
|
2026-02-24 11:43:07 +01:00
|
|
|
];
|
2026-09-25 16:25:31 +02:00
|
|
|
|
2026-02-24 11:43:07 +01:00
|
|
|
return \array_merge(
|
|
|
|
|
$rules,
|
2026-03-03 17:22:33 +01:00
|
|
|
$this->pictureRules('picture', 75, 45, 90, 90)
|
2026-02-24 11:43:07 +01:00
|
|
|
);
|
|
|
|
|
}
|
2026-03-02 16:06:37 +01:00
|
|
|
|
|
|
|
|
public function attributes()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'name' => trans('validation.attributes.name'),
|
|
|
|
|
'picture' => trans('validation.attributes.image'),
|
|
|
|
|
'picture_alt' => trans('validation.custom.attribute_alt'),
|
|
|
|
|
'picture_title' => trans('validation.custom.attribute_title'),
|
|
|
|
|
'category_id' => trans('validattion.custom.category'),
|
|
|
|
|
'page_id' => trans('validattion.custom.static_page_id'),
|
|
|
|
|
|
|
|
|
|
];
|
|
|
|
|
}
|
2026-02-24 11:43:07 +01:00
|
|
|
}
|