Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
StoreQuestionRequest
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 authorize
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 rules
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 attributes
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace App\Http\Requests\Questions;
4
5use App\Enums\QuestionType;
6use Illuminate\Foundation\Http\FormRequest;
7use Kwaadpepper\Enum\Rules\EnumIsValidRule;
8
9class StoreQuestionRequest extends FormRequest
10{
11    /**
12     * Determine if the user is authorized to make this request.
13     *
14     * @return boolean
15     */
16    public function authorize(): bool
17    {
18        return auth()->check();
19    }
20
21    /**
22     * Get the validation rules that apply to the request.
23     *
24     * @return array
25     */
26    public function rules(): array
27    {
28        return [
29            'question' => 'required|string|min:10|max:255',
30            'type' => ['required', new EnumIsValidRule(QuestionType::class)],
31            'brand_id' => 'required|integer|min:0|exists:brands,id',
32        ];
33    }
34
35    /**
36     * Get custom attributes for validator errors.
37     *
38     * @return array
39     */
40    public function attributes(): array
41    {
42        return [
43            'question' => trans('Texte de la question'),
44            'type' => trans('Type de question'),
45            'brand_id' => trans('Id de la marque'),
46        ];
47    }
48}