0
我試圖用laravel 5.5實現管理員/用戶登錄。我創建了管理員模型,與用戶完全一樣,併爲管理員設置了警衛。但登錄時,衛兵不被通過:Laravel後衛不工作
這是我AdminController:
<?php
namespace App\Http\Controllers;
use App\Http\Requests;
use Illuminate\Http\Request;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class AdminController extends Controller{
use AuthenticatesUsers;
protected $guard = 'admin';
public function showLoginForm(){
return view('admin')->with(['title' => 'Panel de Administrador - Iniciar Sesión', 'bodyClass' => 'admin-view']);
}
}
我試圖調試,並走進了供應商的文件夾,以AuthenticatesUsers類和調試要求:
正如您所看到的,它使用用戶模型和網絡守衛。下面是對警衛配置文件:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
]
],
,然後我有供應商:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class
]
],