2
2
3
3
namespace Tests \Controllers ;
4
4
5
- use App \Http \Controllers \Controller ;
6
- use Encore \Admin \Controllers \ModelForm ;
7
- use Encore \Admin \Facades \Admin ;
5
+ use Encore \Admin \Controllers \AdminController ;
8
6
use Encore \Admin \Form ;
9
7
use Encore \Admin \Grid ;
10
- use Encore \Admin \Layout \Content ;
11
8
use Tests \Models \File ;
12
9
13
- class FileController extends Controller
10
+ class FileController extends AdminController
14
11
{
15
- use ModelForm;
16
-
17
- /**
18
- * Index interface.
19
- *
20
- * @return Content
21
- */
22
- public function index ()
23
- {
24
- return Admin::content (function (Content $ content ) {
25
- $ content ->header ('header ' );
26
- $ content ->description ('description ' );
27
-
28
- $ content ->body ($ this ->grid ());
29
- });
30
- }
31
-
32
- /**
33
- * Edit interface.
34
- *
35
- * @param $id
36
- *
37
- * @return Content
38
- */
39
- public function edit ($ id )
40
- {
41
- return Admin::content (function (Content $ content ) use ($ id ) {
42
- $ content ->header ('header ' );
43
- $ content ->description ('description ' );
44
-
45
- $ content ->body ($ this ->form ()->edit ($ id ));
46
- });
47
- }
48
-
49
- /**
50
- * Create interface.
51
- *
52
- * @return Content
53
- */
54
- public function create ()
55
- {
56
- return Admin::content (function (Content $ content ) {
57
- $ content ->header ('Upload file ' );
58
-
59
- $ content ->body ($ this ->form ());
60
- });
61
- }
12
+ protected $ title = 'Files ' ;
62
13
63
14
/**
64
15
* Make a grid builder.
@@ -67,12 +18,14 @@ public function create()
67
18
*/
68
19
protected function grid ()
69
20
{
70
- return Admin::grid (File::class, function (Grid $ grid ) {
71
- $ grid ->id ('ID ' )->sortable ();
21
+ $ grid = new Grid (new File ());
22
+
23
+ $ grid ->id ('ID ' )->sortable ();
72
24
73
- $ grid ->created_at ();
74
- $ grid ->updated_at ();
75
- });
25
+ $ grid ->created_at ();
26
+ $ grid ->updated_at ();
27
+
28
+ return $ grid ;
76
29
}
77
30
78
31
/**
@@ -82,18 +35,20 @@ protected function grid()
82
35
*/
83
36
protected function form ()
84
37
{
85
- return Admin::form (File::class, function (Form $ form ) {
86
- $ form ->display ('id ' , 'ID ' );
38
+ $ form = new Form (new File ());
39
+
40
+ $ form ->display ('id ' , 'ID ' );
41
+
42
+ $ form ->file ('file1 ' );
43
+ $ form ->file ('file2 ' );
44
+ $ form ->file ('file3 ' );
45
+ $ form ->file ('file4 ' );
46
+ $ form ->file ('file5 ' );
47
+ $ form ->file ('file6 ' );
87
48
88
- $ form ->file ('file1 ' );
89
- $ form ->file ('file2 ' );
90
- $ form ->file ('file3 ' );
91
- $ form ->file ('file4 ' );
92
- $ form ->file ('file5 ' );
93
- $ form ->file ('file6 ' );
49
+ $ form ->display ('created_at ' , 'Created At ' );
50
+ $ form ->display ('updated_at ' , 'Updated At ' );
94
51
95
- $ form ->display ('created_at ' , 'Created At ' );
96
- $ form ->display ('updated_at ' , 'Updated At ' );
97
- });
52
+ return $ form ;
98
53
}
99
54
}
0 commit comments