ldc-volena/app/Http/Requests/Bo/Testimonials/StoreTestimonialRequest.php
Jérémy Munsch f3d79cf7a9
Bump with laravel base controller phpstan and phpcs
Still TODO picture sizes for seeders
2024-02-12 15:51:31 +01:00

82 lines
2.4 KiB
PHP

<?php
namespace App\Http\Requests\Bo\Testimonials;
use App\Traits\Requests\HasPicture;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rules\Enum;
class StoreTestimonialRequest extends FormRequest
{
use HasPicture;
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth('backend')->check();
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation()
{
$this->mergePicture('picture');
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
$rules = [
'type' => [
'required',
new Enum(\App\Enums\Testimonials\TypeEnum::class)
],
'name' => 'required|string|between:3,255',
'job' => 'required|string|between:3,255',
'content' => 'required|string|min:3',
'picture_alt' => 'required|string|between:3,255',
'picture_title' => 'required|string|between:3,255',
];
return \array_merge(
$rules,
// FIXME: Mettre à jour les tailles.
$this->pictureRules('picture', 100, 100, 100, 100, false),
);
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
'type' => __('validation.custom.type'),
'name' => __('validation.attributes.name'),
'job' => __('validation.custom.job'),
'content' => __('validation.attributes.content'),
'picture_alt' => __(':field :inter:model', [
'field' => __('validation.custom.alt_attribute'),
'inter' => __('validation.custom.of_the.vowel'),
'model' => __('validation.custom.picture'),
]),
'picture_title' => __(':field :inter:model', [
'field' => __('validation.custom.title_attribute'),
'inter' => __('validation.custom.of_the.vowel'),
'model' => __('validation.custom.picture'),
]),
];
}
}