Authentication 如何在中间件auth中以注册表的形式添加一些变量数据?

Authentication 如何在中间件auth中以注册表的形式添加一些变量数据?,authentication,laravel-5,Authentication,Laravel 5,我想添加一些变量数据以用于注册表表单。类似于选择城市的选项。在普通控制器中,我可以这样做: $data["city"] = City::selectOption(); return View('someView',$data); 如何以注册表形式在miidleware auth中添加一些变量数据?首先,在app\Http\Controllers\auth\AuthController.php类中,只需添加另一个变量 protected function create(array $data)

我想添加一些变量数据以用于注册表表单。类似于选择城市的选项。在普通控制器中,我可以这样做:

$data["city"] = City::selectOption();
return View('someView',$data);

如何以注册表形式在miidleware auth中添加一些变量数据?

首先,在app\Http\Controllers\auth\AuthController.php类中,只需添加另一个变量

protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'variable' => 'value',
        ]);
    }
create方法上的$data数组是get/post请求中的$request变量

其次,在App\User.php中,将变量添加到$filleble

  protected $fillable = [
        'name', 'email', 'password','variable',
    ];
有关更多信息,请查看