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

修改会员


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

php
public function update(Request $request, $id)
{
    $param = $request->param();
    $res = $request->Model->save($param);
    return showSuccess($res);
}

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

php
// 验证规则
protected $rule = [
    'id'=>'require|integer|>:0|isExist:User',
        'status'=>'require|in:0,1',
        'username'=>'require|NotEmpty|length:4,25',
        'password'=>'NotEmpty|min:6',
        'avatar'=>'url',
        'nickname'=>'chsDash',
		'phone'=>'mobile',
		'email'=>'email',
		'user_level_id|会员等级'=>'require|integer|>=:0|isExist:UserLevel,false',
];

protected $scene = [
    ...
    'update'=>['id','username','password','nickname','phone','email','user_level_id','avatar'],
];

路由 router/admin.php

php
Route::post('user/:id','admin.User/update');