ldc-legaulois/app/Http/Requests/Bo/SurveysAnswers/StoreSurveysAnswerRequest.php
2026-09-25 16:25:31 +02:00

52 lines
1.3 KiB
PHP

<?php
namespace App\Http\Requests\Bo\SurveysAnswers;
use App\Models\SurveysAnswer;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Gate;
class StoreSurveysAnswerRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return Gate::check('create', SurveysAnswer::class);
}
/**
* Prepare the data for validation.
*/
protected function prepareForValidation(): void
{
$this->merge([
'published' => $this->boolean('published'),
]);
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
return [
'news_club_id' => 'required|integer|exists:news_clubs,id',
'published' => 'required|boolean',
'answer' => 'required|string|between:3,255',
];
}
/**
* Get custom attributes for validator errors.
*/
public function attributes(): array
{
return [
'news_club_id' => trans_choice('models.classes.news_club', 1),
'published' => trans('validation.attributes.published'),
'answer' => trans('validation.attributes.title'),
];
}
}