Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
CustomerExport
n/a
0 / 0
n/a
0 / 0
3
n/a
0 / 0
 authorize
n/a
0 / 0
n/a
0 / 0
1
 rules
n/a
0 / 0
n/a
0 / 0
2
1<?php
2
3namespace App\Http\Requests;
4
5use App\Enums\CustomerExportType;
6use Illuminate\Foundation\Http\FormRequest;
7
8/**
9 * @codeCoverageIgnore
10 */
11class CustomerExport extends FormRequest
12{
13    /**
14     * Determine if the user is authorized to make this request.
15     *
16     * @return boolean
17     */
18    public function authorize()
19    {
20        return auth()->check();
21    }
22
23    /**
24     * Get the validation rules that apply to the request.
25     *
26     * @return array
27     */
28    public function rules()
29    {
30        return [
31            'brand' => 'required|numeric|exists:brands,id',
32            'export_type' => [
33                'required',
34                'numeric',
35                // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed
36                function ($attribute, $value, $fail) {
37                    if (!\in_array($value, CustomerExportType::values())) {
38                        $fail(trans('Le type d\'export invalide'));
39                    }
40                }
41            ]
42        ];
43    }
44}