46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Http\Requests\Bo\FaqQuestions;
|
|
|
|
use App\Models\FaqQuestion;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Support\Facades\Gate;
|
|
|
|
class StoreFaqQuestionRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function authorize()
|
|
{
|
|
return Gate::check('create', FaqQuestion::class);
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'question' => 'required|string|min:3|max:255',
|
|
'answer' => 'required|string|min:3',
|
|
'theme_id' => 'required|exists:faq_themes,id',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get custom attributes for validator errors.
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'question' => trans('validation.custom.question'),
|
|
'answer' => trans('validation.custom.answer'),
|
|
'theme_id' => trans_choice('models.classes.faq-themes', 1),
|
|
];
|
|
}
|
|
}
|