注册时默认用户组为 1 组

这周末如果不是很懒的话,应该可以把 user profile 模块初步做起来。

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 用户组权限的办法。

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.