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

EquipmentInformationController::submitFieldName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
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 1
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
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