Laravel 方法Illumb\Auth\SessionGuard::Personal不存在
我和Auth有问题。我只是在学习Laravel认证, 我使用的表与默认表不同,我不知道如何使用我的表配置auth。当我尝试登录但显示此错误时:Laravel 方法Illumb\Auth\SessionGuard::Personal不存在,laravel,authentication,Laravel,Authentication,我和Auth有问题。我只是在学习Laravel认证, 我使用的表与默认表不同,我不知道如何使用我的表配置auth。当我尝试登录但显示此错误时: Method Illuminate\Auth\SessionGuard::personnel does not exist. (View: `C:\xampp\htdocs\Laravel\management-app-v6\management-app\resources\views\layouts\app.blade.php)` auth.php
Method Illuminate\Auth\SessionGuard::personnel does not exist. (View: `C:\xampp\htdocs\Laravel\management-app-v6\management-app\resources\views\layouts\app.blade.php)`
auth.php文件:
'defaults' => [
'guard' => 'web',
'passwords' => 'personnels',
],
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'personnels',
],
'api' => [
'driver' => 'token',
'provider' => 'personnels',
'hash' => false,
],
],
'providers' => [
'personnels' => [
'driver' => 'eloquent',
'model' => App\Models\Personnel::class,
],
],
'passwords' => [
'personnels' => [
'provider' => 'personnels',
'table' => 'password_resets',
'expire' => 60,
'throttle' => 60,
],
],
人事模式:
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class Personnel extends Authenticatable
{
use HasFactory, Notifiable;
protected $redirectTo = '/';
protected $guarded = ['id'];
protected $table = "personnels";
protected $fillable = [
'id', 'code_personne', 'nom_personne','prenom_personne', 'qualification', 'fonction','num_cnss', 'montant_cnss',
'salaire_mensuel', 'date_embauche', 'tele', 'chantier_id', 'created_at', 'updated_at'
];
protected $hidden = [
'password',
'remember_token',
];
LoginController中的登录功能:
public function authenticate()
{
request()->validate([
'code_personne' => 'required|string',
'password' => 'required'
]);
if (Auth::attempt(['code_personne' => request()->code_personne, 'password' => request()->password], request()->get('remember'))) {
return redirect()->intended('home');
}
return back()->withInput(request()->only('code_personne', 'remember'));
}
有人能帮我一个忙并提前感谢我吗