我一直在每个资源中搜索这种错误,大多数情况下,他们说该错误是由于config/auth.php
中的错字输入提供程序所致。但是我检查了我的配置,没有错字。这是我的:
'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admin',
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
],
我将我的guards
提供者写到admin
,我的提供者名称是admin
。
我已经运行了Composer Update
命令,一些人要求使用composer update
命令时出现此错误,但对我来说什么也没有。
这是我的身份验证控制器。
public function __construct()
{
$this->middleware('admin',['except' => ['login', 'auth']]);
}
// Login Auth
public function auth(Request $request){
if (Auth::guard('admin')->check()) {
return redirect('/pendaftar');
}
else {
echo "<pre/>"; print_r($request->all());die;//DEBUG
$credentials = $request->only('email', 'password');
if (Auth::guard('admin')->attempt([
'email' =>$request->email,
'password' =>$request->password,
'active' => 'Y'
])
){
return redirect('/pendaftar');
}
else
{
return back()->withErrors([
'message' => Lang::get('auth.failed')
]);
}
}
}
这是我的Admin
模型。
<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Auth\Authenticatable as AuthenticableTrait;
class Admin extends Authenticatable
{
use Notifiable;
protected $fillable = [
'name', 'email', 'jabatan', 'active','password'
];
protected $hidden = [
'password', 'remember_token',
];
}
请给我建议。