On this page
修改角色状态
控制器 app/controller/admin/Role.php
php
public function updateStatus()
{
$role = $this->request->Model;
$role->status = $this->request->param('status');
return showSuccess($role->save());
}
验证器 app/validate/admin/Role.php
php
// 验证规则
protected $rule = [
...
'id'=>'require|integer|>:0|isExist:Role',
'status'=>'require|integer|in:0,1'
...
];
protected $scene = [
...
'updateStatus'=>['id','status'],
];
路由 router/admin.php
php
Route::post('role/:id/update_status','admin.Role/updateStatus');