CategoryRequest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 40
ccs 14
cts 14
cp 1
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 3 1
A rules() 0 3 1
A getCategoryByFilters() 0 13 5
1
<?php
2
3
namespace App\Http\Requests;
4
5
use App\Category;
6
7
class CategoryRequest extends Request
8
{
9
    /**
10
     * Determine if the user is authorized to make this request.
11
     *
12
     * @return bool
13
     */
14 2
    public function authorize()
15
    {
16 2
        return true;
17
    }
18
19
    /**
20
     * Get the validation rules that apply to the request.
21
     *
22
     * @return array
23
     */
24 2
    public function rules()
25
    {
26
        return [
27 2
        ];
28
    }
29
30
    /**
31
     * Build Query with Filters
32
     * @return Category
33
     */
34 2
    public function getCategoryByFilters()
35
    {
36 2
        $category = Category::where('isTeam', '=', $this->isTeam)
37 2
            ->where('gender', '=', $this->gender)
38 2
            ->where('gradeCategory', '=', $this->gradeCategory)
39 2
            ->where('ageCategory', '=', $this->ageCategory);
40
41 2
        $this->has('ageMin') ? $category = $category->where('ageMin', $this->ageMin) : '';
42 2
        $this->has('ageMax') ? $category = $category->where('ageMax', $this->ageMax) : '';
43 2
        $this->has('gradeMin') ? $category = $category->where('gradeMin', $this->gradeMin) : '';
44 2
        $this->has('gradeMax') ? $category = $category->where('gradeMax', $this->gradeMax) : '';
45
46 2
        return $category->select('name')->first() ?? new Category();
47
    }
48
49
}
50