I am using the standard Laravel 5.2 authentication.
But i want to have certain variables available in my Registration view
The route that i'm interested in is this one:
Route::get('register', 'Auth\AuthController@showRegistrationForm');
The method showRegistrationForm is created in a trait called RegistersUsers
, This trait is located in Illuminate\Foundation\Auth
.
public function showRegistrationForm()
{
if (property_exists($this, 'registerView')) {
return view($this->registerView);
}
return view('auth.register');
}
I can just simply pass trough my parameters here, but the problem is that this file is located in the vendor directory , so when i run Composer Update my changes will be overwritten & my website would break. Is there a update-proof way to do this?
答案 0 :(得分:5)
You can overwrite the method in your 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'));
}
}