ldc-crm/app/Http/Requests/Questions/StoreQuestionRequest.php

49 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2023-06-15 12:28:05 +02:00
<?php
namespace App\Http\Requests\Questions;
2023-06-26 10:13:19 +02:00
use App\Enums\QuestionType;
2023-06-15 12:28:05 +02:00
use Illuminate\Foundation\Http\FormRequest;
2023-06-26 10:13:19 +02:00
use Kwaadpepper\Enum\Rules\EnumIsValidRule;
2023-06-15 12:28:05 +02:00
class StoreQuestionRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return boolean
*/
public function authorize(): bool
{
return auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules(): array
{
return [
2023-06-26 10:13:19 +02:00
'question' => 'required|string|min:10|max:255',
'type' => ['required', new EnumIsValidRule(QuestionType::class)],
'brand_id' => 'required|integer|min:0|exists:brands,id',
2023-06-15 12:28:05 +02:00
];
}
/**
* Get custom attributes for validator errors.
*
* @return array
*/
public function attributes(): array
{
return [
2023-06-15 13:15:26 +02:00
'question' => trans('Texte de la question'),
'type' => trans('Type de question'),
'brand_id' => trans('Id de la marque'),
2023-06-15 12:28:05 +02:00
];
}
}