Passed
Push — master ( 65a680...2232db )
by Matthijs
17:59 queued 12:07
created

GeneralSettingController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php namespace App\Http\Controllers\Backend;
2
3
use App\Http\Controllers\Controller;
4
use Illuminate\Http\Request;
5
use Notification;
6
use Datatables;
0 ignored issues
show
Bug introduced by
The type Datatables was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Form;
8
9
use Hideyo\Ecommerce\Framework\Services\GeneralSetting\GeneralSettingFacade as GeneralSettingService;
10
11
class GeneralSettingController extends Controller
12
{
13
    public function index(Request $request)
14
    {
15
        if ($request->wantsJson()) {
16
17
            $query = GeneralSettingService::getModel()->select(
18
                [
19
                
20
                'id',
21
                'name', 'value']
22
            )->where('shop_id', '=', auth('hideyobackend')->user()->selected_shop_id);
0 ignored issues
show
Bug introduced by
Accessing selected_shop_id on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
23
            
24
            $datatables = Datatables::of($query)->addColumn('action', function ($query) {
25
                $deleteLink = Form::deleteajax(url()->route('general-setting.destroy', $query->id), 'Delete', '', array('class'=>'btn btn-sm btn-danger'));
26
                $links = '<a href="'.url()->route('general-setting.edit', $query->id).'" class="btn btn-sm btn-success"><i class="fi-pencil"></i>Edit</a>  '.$deleteLink;
27
                return $links;
28
            });
29
30
            return $datatables->make(true);
31
        }
32
        
33
        return view('backend.general-setting.index')->with('generalSetting', GeneralSettingService::selectAll());
34
    }
35
36
    public function create()
37
    {
38
        return view('backend.general-setting.create')->with(array());
39
    }
40
41
    public function store(Request $request)
42
    {
43
        $result  = GeneralSettingService::create($request->all());
44
        return GeneralSettingService::notificationRedirect('general-setting.index', $result, 'The general setting was inserted.');
45
    }
46
47
    public function edit($generalSettingId)
48
    {
49
        return view('backend.general-setting.edit')->with(array('generalSetting' => GeneralSettingService::find($generalSettingId)));
50
    }
51
52
    public function update(Request $request, $generalSettingId)
53
    {
54
        $result  = GeneralSettingService::updateById($request->all(), $generalSettingId);
55
        return GeneralSettingService::notificationRedirect('general-setting.index', $result, 'The general setting was updated.');
56
    }
57
58
    public function destroy($generalSettingId)
59
    {
60
        $result  = GeneralSettingService::destroy($generalSettingId);
61
        if ($result) {
62
            Notification::error('The general setting was deleted.');
63
            return redirect()->route('general-setting.index');
64
        }
65
    }
66
}
67