Passed
Push — dev5a ( 386e30...9eb7a1 )
by Ron
07:53
created

EquipmentInformationController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 27
ccs 14
cts 14
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A deleteField() 0 5 1
A submitFieldName() 0 5 1
A index() 0 4 1
A newField() 0 4 1
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 2
    public function newField(NewFieldRequest $request)
25
    {
26 2
        (new SetEquipmentDataFields)->processNewField($request->name, $request->hidden);
27 2
        return response()->json(['success' => true]);
28
    }
29
30 2
    public function submitFieldName(EditFieldRequest $request)
31
    {
32 2
        (new SetEquipmentDataFields)->editExistingField($request->data_type_id, $request->name, $request->hidden);
33 2
        Log::info('Data Field Type ID '.$request->data_type_id.' was updated by '.Auth::user()->full_name.'.  Data - ', $request->toArray());
34 2
        return response()->json(['success' => true]);
35
    }
36
37 2
    public function deleteField($id)
38
    {
39 2
        (new SetEquipmentDataFields)->deleteField($id);
40 2
        Log::notice('Data Field Type ID - '.$id.' was deleted by '.Auth::user()->full_name);
41 2
        return response()->json(['success' => true]);
42
    }
43
}
44