|
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
|
|
|
|