gpt4 book ai didi

php - 调用未定义的方法 Illuminate\Auth\TokenGuard::attempt()

转载 作者:可可西里 更新时间:2023-10-31 22:40:14 26 4
gpt4 key购买 nike

我收到这个错误:

Call to undefined method Illuminate\Auth\TokenGuard::attempt()

来自这段代码:

if(Auth::guard('admin')->attempt(['email' => $request->email, 'password' => $request->password], $request->remember)){
return redirect()->intended(route('admin.dashboard'));
}else{

我已经导入了Illuminate\Support\Facades\Auth as the docs suggest

我的 auth.php 可能有帮助

<?php

return [

'defaults' => [
'guard' => 'web',
'passwords' => 'users',
],
'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,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
],
],
'passwords' => [
'users' => [
'provider' => 'users',
'table' => 'password_resets',
'expire' => 60,
],
'admins' => [
'provider' => 'admins',
'table' => 'password_resets',
'expire' => 15,
],
],
];

最佳答案

我认为您可能正在尝试使用“ session ”防护驱动程序而不是“ token ”。所以,尝试这样做:

config/auth.php配置文件中:

'admin-api' => [
'driver' => 'token',
'provider' => 'admins',
],

你必须把它改成

'admin-api' => [
'driver' => 'session',
'provider' => 'admins',
],

然后你应该运行:

 php artisan cache:clear
php artisan config:cache

再试一次。祝你好运!

关于php - 调用未定义的方法 Illuminate\Auth\TokenGuard::attempt(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46003253/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com