注册时默认用户组为 1 组
这周末如果不是很懒的话,应该可以把 user profile 模块初步做起来。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
protected function create(array $data) { $user=User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password']) ]); $profile=new Profile(['nickname'=>$data['name']]); $user->profiles()->save($profile); $user->profiles->group_id=1; $user->profiles->save(); return $user; } |
目前 group_id 显然不能放在 mass assign 中,于是采取了先新建记录,再 update 用户组权限的办法。