我想在注册过程中用户可以选择一个组,并将用户注册到他们的组
例如在注册时有 2 个组,“自由职业者”和“雇主”
谢谢您的帮助
我想在注册过程中用户可以选择一个组,并将用户注册到他们的组
例如在注册时有 2 个组,“自由职业者”和“雇主”
谢谢您的帮助
我不相信您可以使用现有的用户插件帐户组件来做到这一点。主要是因为它使用 Auth::register() 来保存新用户并且那里没有保存关系。
您可以创建自己的组件来扩展帐户组件,并从您自己的表单调用 onRegisterPlus() 函数。
public function onRegisterPlus()
{
$this->onRegister();// call the accout component onRegister method
/** You may want to do some verification here that this
is a new registraion to prevent submitting existing
email and changing the groups.
or not use $this->onRegister() and just copy it to
your own method and modify to fit your needs.
*/
if($user= User::where('email',post('email'))->first()){
$user->groups()->sync(post('groups'))
}
}
您将按照上述方式制作表单,并在名为“groups[]”的复选框中包含您希望可用的组的值。