Passed
Push — dev5a ( 8099d5...bf034e )
by Ron
07:35
created

CustomerEquipmentController::show()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App\Http\Controllers\Customers;
4
5
use App\Domains\Customers\GetCustomerEquipment;
6
use App\Domains\Customers\SetCustomerEquipment;
7
use App\Domains\Equipment\GetEquipment;
8
use App\Http\Controllers\Controller;
9
use App\Http\Requests\Customers\CustomerEquipmentRequest;
10
use Illuminate\Http\Request;
11
use Illuminate\Support\Facades\Auth;
12
use Illuminate\Support\Facades\Log;
13
14
class CustomerEquipmentController extends Controller
15
{
16
    //  Get a list of all equipment that can be attached to the customer
17 2
    public function index()
18
    {
19 2
        return (new GetEquipment)->getAllEquipment(true);
20
    }
21
22
    //  Store a new equipment type for the customer
23 2
    public function store(CustomerEquipmentRequest $request)
24
    {
25 2
        (new SetCustomerEquipment)->createNewEquipment($request, $request->cust_id);
26 2
        return response()->json(['success' => true]);
27
    }
28
29
    //  Get Customer equipment
30 1
    public function show($id)
31
    {
32 1
        return (new GetCustomerEquipment)->execute($id);
33
    }
34
35
    //  Update a customers existing equipment
36 2
    public function update(CustomerEquipmentRequest $request, $id)
37
    {
38 2
        (new SetCustomerEquipment)->updateExistingEquipment($request, $request->cust_id, $id);
39 2
        return response()->json(['success' => true]);
40
    }
41
42
    //  Delete equipment from a customer
43 2
    public function destroy($id)
44
    {
45 2
        (new SetCustomerEquipment)->deleteEquip($id);
46 2
        Log::notice('Equipment ID '.$id.' deleted by '.Auth::user()->full_name);
47 2
        return response()->json(['success' => true]);
48
    }
49
}
50