10
10
11
11
class CategoryController extends Controller
12
12
{
13
- /**
14
- * @var int 默认分页条数
15
- */
16
- public $ perPage = 10 ;
17
-
18
13
/**
19
14
* Create a new AuthController instance.
20
15
* 要求附带email和password(数据来源users表)
21
16
*
22
17
* @return void
23
18
*/
24
- public function __construct (Request $ request )
19
+ public function __construct ()
25
20
{
26
21
// 这里额外注意了:官方文档样例中只除外了『login』
27
22
// 这样的结果是,token 只能在有效期以内进行刷新,过期无法刷新
@@ -30,9 +25,6 @@ public function __construct(Request $request)
30
25
$ this ->middleware (['auth:api ' , 'role ' ]);
31
26
// 另外关于上面的中间件,官方文档写的是『auth:api』
32
27
// 但是我推荐用 『jwt.auth』,效果是一样的,但是有更加丰富的报错信息返回
33
-
34
- $ perPage = intval ($ request ->input ('perPage ' ));
35
- $ this ->perPage = $ perPage ?? 11 ;
36
28
}
37
29
38
30
/**
@@ -42,7 +34,7 @@ public function __construct(Request $request)
42
34
*/
43
35
public function index ()
44
36
{
45
- $ list = Category::orderBy ('sort ' )->paginate ($ this ->perPage );
37
+ $ list = Category::orderBy ('sort ' )->paginate ($ this ->getPerPage () );
46
38
return $ this ->out (200 , $ list );
47
39
}
48
40
@@ -95,7 +87,7 @@ public function show(Category $Category)
95
87
* Show the form for editing the specified resource.
96
88
* 编辑展示数据
97
89
*
98
- * @param int $id
90
+ * @param int $id
99
91
*
100
92
* @return \Illuminate\Http\Response
101
93
*/
@@ -109,8 +101,8 @@ public function edit($id)
109
101
* Update the specified resource in storage.
110
102
* 更新数据
111
103
*
112
- * @param Update $request
113
- * @param int $id
104
+ * @param Update $request
105
+ * @param int $id
114
106
* @return \Illuminate\Http\Response
115
107
*/
116
108
public function update (Update $ request , $ id )
@@ -130,7 +122,7 @@ public function update(Update $request, $id)
130
122
/**
131
123
* Remove the specified resource from storage.
132
124
*
133
- * @param int $id
125
+ * @param int $id
134
126
* @return \Illuminate\Http\Response
135
127
* @throws \Exception
136
128
*/
0 commit comments