3
3
namespace DummyNamespace;
4
4
5
5
use DummyModelNamespace;
6
-
6
+ use App\Http\Controllers\Controller;
7
+ use Encore\Admin\Controllers\HasResourceActions;
7
8
use Encore\Admin\Form;
8
9
use Encore\Admin\Grid;
9
- use Encore\Admin\Facades\Admin;
10
10
use Encore\Admin\Layout\Content;
11
- use App\Http\Controllers\Controller;
12
- use Encore\Admin\Controllers\ModelForm;
13
11
use Encore\Admin\Show;
14
12
15
13
class DummyClass extends Controller
16
14
{
17
- use ModelForm ;
15
+ use HasResourceActions ;
18
16
19
17
/**
20
18
* Index interface.
21
19
*
20
+ * @param Content $content
22
21
* @return Content
23
22
*/
24
- public function index()
23
+ public function index(Content $content )
25
24
{
26
- return Admin::content(function (Content $content) {
27
-
28
- $content->header('header');
29
- $content->description('description');
30
-
31
- $content->body($this->grid());
32
- });
25
+ return $content
26
+ ->header('Index')
27
+ ->description('description')
28
+ ->body($this->grid());
33
29
}
34
30
35
31
/**
36
32
* Show interface.
37
33
*
38
- * @param mixed $id
34
+ * @param mixed $id
39
35
* @param Content $content
40
- *
41
36
* @return Content
42
37
*/
43
- public function show($id)
38
+ public function show($id, Content $content )
44
39
{
45
- return Admin::content(function (Content $content) use ($id) {
46
-
47
- $content->header('Header');
48
- $content->description('Description');
49
-
50
- $content->body(Admin::show(DummyModel::findOrFail($id), function (Show $show) {
51
-
52
- $show->id('ID');
53
-
54
- }));
55
- });
40
+ return $content
41
+ ->header('Detail')
42
+ ->description('description')
43
+ ->body($this->detail($id));
56
44
}
57
45
58
46
/**
59
47
* Edit interface.
60
48
*
61
- * @param $id
49
+ * @param mixed $id
50
+ * @param Content $content
62
51
* @return Content
63
52
*/
64
- public function edit($id)
53
+ public function edit($id, Content $content )
65
54
{
66
- return Admin::content(function (Content $content) use ($id) {
67
-
68
- $content->header('header');
69
- $content->description('description');
70
-
71
- $content->body($this->form()->edit($id));
72
- });
55
+ return $content
56
+ ->header('Edit')
57
+ ->description('description')
58
+ ->body($this->form()->edit($id));
73
59
}
74
60
75
61
/**
76
62
* Create interface.
77
63
*
64
+ * @param Content $content
78
65
* @return Content
79
66
*/
80
- public function create()
67
+ public function create(Content $content )
81
68
{
82
- return Admin::content(function (Content $content) {
83
-
84
- $content->header('header');
85
- $content->description('description');
86
-
87
- $content->body($this->form());
88
- });
69
+ return $content
70
+ ->header('Create')
71
+ ->description('description')
72
+ ->body($this->form());
89
73
}
90
74
91
75
/**
@@ -95,13 +79,30 @@ class DummyClass extends Controller
95
79
*/
96
80
protected function grid()
97
81
{
98
- return Admin::grid(DummyModel::class, function (Grid $grid) {
82
+ $grid = new Grid(new DummyModel);
83
+
84
+ $grid->id('ID');
85
+ $grid->created_at('Created at');
86
+ $grid->updated_at('Updated at');
87
+
88
+ return $grid;
89
+ }
90
+
91
+ /**
92
+ * Make a show builder.
93
+ *
94
+ * @param mixed $id
95
+ * @return Show
96
+ */
97
+ protected function detail($id)
98
+ {
99
+ $show = new Show(DummyModel::findOrFail($id));
99
100
100
- $grid->id('ID')->sortable();
101
+ $show->id('ID');
102
+ $show->created_at('Created at');
103
+ $show->updated_at('Updated at');
101
104
102
- $grid->created_at();
103
- $grid->updated_at();
104
- });
105
+ return $show;
105
106
}
106
107
107
108
/**
@@ -111,12 +112,12 @@ class DummyClass extends Controller
111
112
*/
112
113
protected function form()
113
114
{
114
- return Admin:: form(DummyModel::class, function ( Form $form) {
115
+ $ form = new Form(new DummyModel);
115
116
116
- $form->display('id', 'ID');
117
+ $form->display('ID');
118
+ $form->display('Created at');
119
+ $form->display('Updated at');
117
120
118
- $form->display('created_at', 'Created At');
119
- $form->display('updated_at', 'Updated At');
120
- });
121
+ return $form;
121
122
}
122
123
}
0 commit comments