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(); |
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function getEditInfo(ComponentInterface $component, $id) |
|
|
|
|
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)); |
|
|
|
|
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) |
|
|
|
|
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
|
|
|
|
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.