我已经为我的用户身份验证完成了,现在我只是为了使用admin身份验证,并且它没有回复我的数据库用户名&密码。 fyi,我在phpmyadmin手动创建了管理员表。所以在迁移文件夹中没有create_admin_table.php文件。帮助:(
这是我的控制器
use Illuminate\Support\Facades;
use Hash;
use Auth;
use App\Admin; // i created this Model for admin
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Http\Requests;
function login(Request $req){
$email = $req->input('email');
$password = $req->input('password');
if(Auth::guard('admin')->attempt([
'email' => $email,
'password' => $password
]))
{
return redirect('/signin');
}else{
return redirect('/Admin/signin');
}
}
我的内核:
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'admin' => \App\Http\Middleware\RedirectIfNotAdmin::class,
];
我的身份证明:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'admin-api' => [
'driver' => 'token',
'provider' => 'admins',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users',
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
'table' => 'admins',
],
],