GlossaryStoreRequest::rules()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 0
dl 0
loc 14
ccs 0
cts 5
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Http\Requests;
4
5
use App\Rules\LettersAndWhitespaces;
6
use Illuminate\Foundation\Http\FormRequest;
7
8
class GlossaryStoreRequest extends FormRequest
9
{
10
    /**
11
     * Determine if the user is authorized to make this request.
12
     *
13
     * @return bool
14
     */
15
    public function authorize()
16
    {
17
        return true;
18
    }
19
20
    /**
21
     * Get the validation rules that apply to the request.
22
     *
23
     * @return array
24
     */
25
    public function rules()
26
    {
27
        $rules = [
28
            'term' => ['required', 'max:255', new LettersAndWhitespaces()],
29
            'definition' => ['required', 'string'],
30
            'body' => ['nullable', 'string'],
31
            'question_type' => ['required', 'string'],
32
        ];
33
34
        if (request()->hasFile('introimage')) {
35
            $rules['introimage'] = ['nullable', 'image','mimes:jpg,jpeg,png','max:5120']; // 5MB
36
        }
37
38
        return $rules;
39
    }
40
}
41