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

49 lines
1.1 KiB
PHP
Raw Normal View History

2023-06-15 12:28:05 +02:00
<?php
2023-10-06 15:00:42 +02:00
namespace App\Http\Requests\Bo\Questions;
2023-06-15 12:28:05 +02:00
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-09-04 13:08:34 +02:00
use Illuminate\Validation\Rules\Enum;
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
{
2023-10-06 15:00:42 +02:00
return auth('backend')->check();
}
2023-06-15 12:28:05 +02:00
/**
* 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',
2023-09-04 13:08:34 +02:00
'type' => ['required', new Enum(QuestionType::class)],
2023-06-26 10:13:19 +02:00
'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'),
2023-09-04 13:08:34 +02:00
'type' => trans('Type de question'),
2023-06-15 13:15:26 +02:00
'brand_id' => trans('Id de la marque'),
2023-06-15 12:28:05 +02:00
];
}
}