Passed
Push — dev5a ( bf2271...c9bcfe )
by Ron
08:07
created

GetEquipment::getEquipmentArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 7
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 14
ccs 8
cts 8
cp 1
crap 2
rs 10
1
<?php
2
3
namespace App\Domains\Equipment;
4
5
use App\SystemTypes;
6
use App\SystemCategories;
7
8
use Illuminate\Support\Facades\Auth;
9
use Illuminate\Support\Facades\Log;
10
11
12
class GetEquipment
13
{
14 6
    public function getAllEquipment($incCat = false)
15
    {
16 6
        if($incCat)
17
        {
18 4
            $list = SystemCategories::with('SystemTypes')->get();
19
        }
20
        else
21
        {
22 2
            $list = SystemTypes::all();
23
        }
24
25 6
        return $list;
26
    }
27
28 2
    public function getEquipmentArray()
29
    {
30 2
        $list = SystemTypes::orderBy('cat_id', 'ASC')->orderBy('name', 'ASC')->get();
31
32 2
        $newList = [];
33 2
        foreach($list as $item)
34
        {
35 2
            $newList[] = [
36 2
                'value' => $item->sys_id,
37 2
                'text'  => $item->name,
38
            ];
39
        }
40
41 2
        return $newList;
42
    }
43
44 4
    public function getCatList()
45
    {
46 4
        return SystemCategories::all();
47
    }
48
49 4
    public function getEquipmentData($sysID)
50
    {
51 4
        return SystemTypes::where('sys_id', $sysID)->with('SystemDataFields')->first();
52
    }
53
}
54