Passed
Push — dev5a ( f24c41...668142 )
by Ron
10:56
created

SetCategory::updateCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Domains\Equipment;
4
5
use App\SystemCategories;
6
use Illuminate\Support\Facades\Auth;
7
use Illuminate\Support\Facades\Log;
8
9
10
class SetCategory
11
{
12 4
    public function createCategory($request)
13
    {
14 4
        SystemCategories::create([
15 4
            'name' => $request->name,
16
        ]);
17
18 4
        return true;
19
    }
20
21 4
    public function updateCategory($request, $catID)
22
    {
23 4
        SystemCategories::findOrFail($catID)->update([
24 4
            'name' => $request->name,
25
        ]);
26
27 4
        return true;
28
    }
29
30 8
    public function deleteCategory($catID)
31
    {
32
        try
33
        {
34 8
            SystemCategories::findOrFail($catID)->delete();
35 4
            return true;
36
        }
37 4
        catch(\Illuminate\Database\QueryException $e)
38
        {
39 4
            Log::warning('An attempt to delete Equipment Category ID '.$catID.' failed.  Reason - ', array($e));
40 4
            return false;
41
        }
42
    }
43
}
44