1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers\Admin; |
4
|
|
|
|
5
|
|
|
use App\Domains\Equipment\GetEquipDataFields; |
6
|
|
|
use App\Domains\Equipment\SetEquipmentDataFields; |
7
|
|
|
use App\Http\Controllers\Controller; |
8
|
|
|
use App\Http\Requests\Equipment\EditFieldRequest; |
9
|
|
|
use App\Http\Requests\Equipment\NewFieldRequest; |
10
|
|
|
use Illuminate\Http\Request; |
11
|
|
|
|
12
|
|
|
use Illuminate\Support\Facades\Auth; |
13
|
|
|
use Illuminate\Support\Facades\Log; |
14
|
|
|
|
15
|
|
|
class EquipmentInformationController extends Controller |
16
|
|
|
{ |
17
|
2 |
|
public function index() |
18
|
|
|
{ |
19
|
2 |
|
return view('admin.equipment.equipmentInformation', [ |
20
|
2 |
|
'fields' => (new GetEquipDataFields)->getAllFieldsWithStats(), |
21
|
|
|
]); |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public function getFields($sysID) |
25
|
|
|
{ |
26
|
|
|
return (new GetEquipDataFields)->getFieldsForEquip($sysID); |
27
|
|
|
} |
28
|
|
|
|
29
|
2 |
|
public function newField(NewFieldRequest $request) |
30
|
|
|
{ |
31
|
2 |
|
(new SetEquipmentDataFields)->processNewField($request->name, $request->hidden); |
32
|
2 |
|
return response()->json(['success' => true]); |
33
|
|
|
} |
34
|
|
|
|
35
|
2 |
|
public function submitFieldName(EditFieldRequest $request) |
36
|
|
|
{ |
37
|
2 |
|
(new SetEquipmentDataFields)->editExistingField($request->data_type_id, $request->name, $request->hidden); |
38
|
2 |
|
Log::info('Data Field Type ID '.$request->data_type_id.' was updated by '.Auth::user()->full_name.'. Data - ', $request->toArray()); |
39
|
2 |
|
return response()->json(['success' => true]); |
40
|
|
|
} |
41
|
|
|
|
42
|
2 |
|
public function deleteField($id) |
43
|
|
|
{ |
44
|
2 |
|
(new SetEquipmentDataFields)->deleteField($id); |
45
|
2 |
|
Log::notice('Data Field Type ID - '.$id.' was deleted by '.Auth::user()->full_name); |
46
|
2 |
|
return response()->json(['success' => true]); |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|