1010
1111class CategoryController extends Controller
1212{
13- /**
14- * @var int 默认分页条数
15- */
16- public $ perPage = 10 ;
17-
1813 /**
1914 * Create a new AuthController instance.
2015 * 要求附带email和password(数据来源users表)
2116 *
2217 * @return void
2318 */
24- public function __construct (Request $ request )
19+ public function __construct ()
2520 {
2621 // 这里额外注意了:官方文档样例中只除外了『login』
2722 // 这样的结果是,token 只能在有效期以内进行刷新,过期无法刷新
@@ -30,9 +25,6 @@ public function __construct(Request $request)
3025 $ this ->middleware (['auth:api ' , 'role ' ]);
3126 // 另外关于上面的中间件,官方文档写的是『auth:api』
3227 // 但是我推荐用 『jwt.auth』,效果是一样的,但是有更加丰富的报错信息返回
33-
34- $ perPage = intval ($ request ->input ('perPage ' ));
35- $ this ->perPage = $ perPage ?? 11 ;
3628 }
3729
3830 /**
@@ -42,7 +34,7 @@ public function __construct(Request $request)
4234 */
4335 public function index ()
4436 {
45- $ list = Category::orderBy ('sort ' )->paginate ($ this ->perPage );
37+ $ list = Category::orderBy ('sort ' )->paginate ($ this ->getPerPage () );
4638 return $ this ->out (200 , $ list );
4739 }
4840
@@ -95,7 +87,7 @@ public function show(Category $Category)
9587 * Show the form for editing the specified resource.
9688 * 编辑展示数据
9789 *
98- * @param int $id
90+ * @param int $id
9991 *
10092 * @return \Illuminate\Http\Response
10193 */
@@ -109,8 +101,8 @@ public function edit($id)
109101 * Update the specified resource in storage.
110102 * 更新数据
111103 *
112- * @param Update $request
113- * @param int $id
104+ * @param Update $request
105+ * @param int $id
114106 * @return \Illuminate\Http\Response
115107 */
116108 public function update (Update $ request , $ id )
@@ -130,7 +122,7 @@ public function update(Update $request, $id)
130122 /**
131123 * Remove the specified resource from storage.
132124 *
133- * @param int $id
125+ * @param int $id
134126 * @return \Illuminate\Http\Response
135127 * @throws \Exception
136128 */
0 commit comments