Skip to content
关注公众号,获取新课通知

修改角色


控制器 app/controller/admin/Role.php

php
public function update(Request $request, $id)
{
	$param = $request->only([
		'id',
		'status',
		'desc',
		'name',
	]);
	$res = $request->Model->save($param);
	return showSuccess($res);
}

验证器 app/validate/admin/Role.php

php
// 验证规则
protected $rule = [
	'id'=>'require|integer|>:0|isExist:Role',
    'status'=>'require|in:0,1',
    'name'=>'require',
];

protected $scene = [
	...
	'update'=>['id','status','name'],
];

路由 router/admin.php

php
Route::post('role/:id','admin.Role/update');