我需要使用内置的auth将无关模型的数据传递到寄存器视图中。实现这一目标的最干净的方法是什么?
这就是Auth控制器中的内容:
public function __construct(Guard $auth, Registrar $registrar)
{
$this->auth = $auth;
$this->registrar = $registrar;
$this->middleware('guest', ['except' => 'getLogout']);
}发布于 2015-09-08 23:15:04
解决办法比我预期的要容易得多。要将数据传递给寄存器视图,只需覆盖AuthController中的AuthController方法并将数据传递给视图:
public function getRegister()
{
$products = \App\Product::all();
$data = [
'products' => $products
];
return view('auth.register')->with($data);
}发布于 2016-12-25 04:01:45
在这里,我得到了解决办法,当我面临类似的问题与你。
第一步
你可以找到拉拉挂号站的行动路线。只需输入"php artisan路由:list“
如果您使用的是Laravel5.3,可以在方法中找到。
第二步.
添加新方法作为showRegistrationForm方法在RegisterController.php中的过脊
public function showRegistrationForm()
{
$product = Product::all();
return view("auth.register", compact("product"));
}在旧版本中,它使用getRegister方法重写操作。
希望这能有所帮助。
发布于 2018-10-17 18:22:32
在Laravel5.7中,您只需重写在vendor\laravel\framework\src\Illuminate\Foundation\Auth上找到的showRegistrationForm()方法
public function showRegistrationForm()
{
//Custom code here
return view('auth.register');
}https://stackoverflow.com/questions/32464984
复制相似问题