如何在Laravel 5中创建用户登录/注册页和业务登录/注册页。我的AuthController使用:
use AuthenticatesAndRegistersUsers, ThrottlesLogins;我的routes.php正在使用:
Route::auth();这对于用户注册来说是可以的。如何为与用户不同的另一个实体添加单独的注册?
发布于 2016-01-29 18:06:42
您可以指定到不同控制器和/或操作的不同路由。
示例:
Route::auth();
$this->get('b_login', 'Auth\AuthController@showBusinessLoginForm');
$this->post('b_login', 'Auth\AuthController@businessLogin');现在,您可以在Auth\AuthController中实现业务登录操作。
编辑
我注意到为业务注册/登录操作使用第二个控制器更简单。而不能在每个控制器中使用AuthenticatesAndRegistersUsers特性。这意味着您只需覆盖您想要适应的操作。
可能看起来像这样:
routes.php
Route::auth();
$this->get('b_login', 'Auth\BusinessAuthController@showLoginForm');
$this->post('b_login', 'Auth\BusinessAuthController@login');Auth/AuthController.php
...
use AuthenticatesAndRegistersUsers;
protected $redirectPath = '/home';
// do some other stuff
...Auth/BusinessAuthController.php
...
use AuthenticatesAndRegistersUsers;
protected $redirectPath = '/home-business';
// for checking $user->is_business_user == 1 while attemping login
protected function getCredentials(Request $request){
$credentials = $request->only($this->loginUsername(), 'password');
$credentials['is_business_user'] = 1;
return $credentials;
}
// do some other stuff
...https://stackoverflow.com/questions/35091024
复制相似问题