我正在创建一个管理员面板,管理员可以在其中创建用户。我使用了laravel默认注册系统。我已经修改了RegisterController。用户正在成功创建。但问题是在创建用户之后管理员正在注销。问题是什么? 这是我的文件。我正在使用laravel 5.3
web.php
Route::group(['middleware' => 'auth:admin'], function () {
Route::get('/admin/user/register','Auth\CreateUserController@showRegistrationForm');
Route::post('/admin/user/register','Auth\CreateUserController@register');
});
CreateUserController
class CreateUserController extends Controller
{
use RegistersUsers;
protected function redirectTo()
{
if(Auth::guard('admin')->check()) return '/admin/index';
else if(Auth::guard('employee')->check()) return '/employee/dashboard';
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
'district' => 'required',
'gender' => 'required',
'mobile' => 'required',
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
'district' =>$data['district'],
'mobile' => $data['mobile'],
'gender'=>$data['gender'],
]);
}
}