Completed
Push — master ( 1e692e...0e6a09 )
by wen
03:03
created

AdminController::getCreate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace Sco\Admin\Http\Controllers;
4
5
use Illuminate\Auth\Access\AuthorizationException;
6
use Illuminate\Routing\Controller;
7
use Sco\Admin\Contracts\ComponentInterface;
8
use Sco\Admin\Contracts\ModelFactoryInterface;
9
10
class AdminController extends Controller
11
{
12
    public function index()
13
    {
14
        return view('admin::app');
15
    }
16
17
    public function getList(ComponentInterface $component)
18
    {
19
        if (!$component->isView()) {
20
            throw new AuthorizationException();
21
        }
22
23
        return $component->get();
24
    }
25
26
27
    public function config(ComponentInterface $component)
28
    {
29
        if (!$component->isView()) {
30
            throw new AuthorizationException();
31
        }
32
33
        return $component->getConfigs();
34
    }
35
36
    public function getCreateInfo(ComponentInterface $component)
37
    {
38
        if (!$component->isCreate()) {
39
            throw new AuthorizationException();
40
        }
41
        
42
    }
43
44
    public function create(ComponentInterface $component)
45
    {
46
        if (!$component->isCreate()) {
47
            throw new AuthorizationException();
48
        }
49
50
        return view('admin::app');
51
    }
52
53
    public function store(ComponentInterface $component)
54
    {
55
        if (!$component->isCreate()) {
56
            throw new AuthorizationException();
57
        }
58
59
        $component->store();
0 ignored issues
show
Bug introduced by
The method store() does not seem to exist on object<Sco\Admin\Contracts\ComponentInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60
    }
61
62
    public function getEditInfo(ComponentInterface $component, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
63
    {
64
        if (!$component->isEdit()) {
65
            throw new AuthorizationException();
66
        }
67
68
    }
69
70
    public function edit(ComponentInterface $component, $id)
71
    {
72
        if (!$component->isEdit()) {
73
            throw new AuthorizationException();
74
        }
75
76
        dd($component->find($id));
0 ignored issues
show
Bug introduced by
The method find() does not seem to exist on object<Sco\Admin\Contracts\ComponentInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
77
    }
78
79
    public function update()
80
    {
81
    }
82
83
    public function delete(ModelFactoryInterface $modelFactory, $id)
84
    {
85
        $modelFactory->delete($id);
86
        return response()->json(['message' => 'ok']);
87
    }
88
89
    public function batchDelete(ModelFactoryInterface $modelFactory)
0 ignored issues
show
Unused Code introduced by
The parameter $modelFactory is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
90
    {
91
    }
92
93
    public function forceDelete(ModelFactoryInterface $modelFactory, $id)
94
    {
95
        $modelFactory->forceDelete($id);
96
        return response()->json(['message' => 'ok']);
97
    }
98
99
    public function restore(ModelFactoryInterface $modelFactory, $id)
100
    {
101
        $modelFactory->restore($id);
102
        return response()->json(['message' => 'ok']);
103
    }
104
}
105