我正在使用标准的 Laravel 5.2 身份验证。
但我想在我的注册 View 中提供某些变量
我感兴趣的路线是这条:
Route::get('register', 'Auth\AuthController@showRegistrationForm');
showRegistrationForm 方法是在 trait called RegistersUsers
中创建的,这个性状位于Illuminate\Foundation\Auth
.
public function showRegistrationForm()
{
if (property_exists($this, 'registerView')) {
return view($this->registerView);
}
return view('auth.register');
}
我可以在这里简单地传递我的参数,但问题是这个文件位于 vendor 目录中,所以当我运行 Composer Update 时,我的更改将被覆盖并且我的网站会崩溃。有没有更新证明的方法来做到这一点?
最佳答案
您可以覆盖 AuthController 中的方法:
class AuthController extends Controller
{
....
public function showRegistrationForm()
{
$data = ['foo', 'bar'];
if (property_exists($this, 'registerView')) {
return view($this->registerView, compact('data'));
}
return view('auth.register', compact('data'));
}
}
关于php - 在 Laravel 5.2 Registry Form Update-proof 中传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36650436/