CreateCategoryRequest::rules()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 9
cp 0
cc 2
eloc 7
nc 2
nop 0
crap 6
1
<?php namespace Arcanesoft\Blog\Http\Requests\Admin\Categories;
2
3
/**
4
 * Class     CreateCategoryRequest
5
 *
6
 * @package  Arcanesoft\Blog\Http\Requests\Admin\Categories
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
class CreateCategoryRequest extends CategoryFormRequest
10
{
11
    /* -----------------------------------------------------------------
12
     |  Main Methods
13
     | -----------------------------------------------------------------
14
     */
15
16
    /**
17
     * Determine if the user is authorized to make this request.
18
     *
19
     * @return bool
20
     */
21
    public function authorize()
22
    {
23
        return true;
24
    }
25
26
    /**
27
     * Get the validation rules that apply to the request.
28
     *
29
     * @return array
30
     */
31
    public function rules()
32
    {
33
        $rules = [];
34
35
        // TODO: Adding an 'exists' rule to check if the name exists
36
        if ($this->isTranslatable())
37
            $rules['name.*'] = ['required', 'string', 'min:3'];
38
        else
39
            $rules['name'] = ['required', 'string', 'min:3'];
40
41
        return $rules;
42
    }
43
}
44