【问题标题】:Laravel returns the error "Argument 1 passed to ...validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable"Laravel 返回错误“传递给 ...validateCredentials() 的参数 1 必须是 Illuminate\Contracts\Auth\Authenticatable 的实例”
【发布时间】:2020-07-02 06:12:31
【问题描述】:

用户.php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable
{
    protected $fillable = ['name','email','password'];

}

尝试登录 Laravel 时发生错误。

错误:

传递给 Illuminate\Auth\EloquentUserProvider::validateCredentials() 的参数 1 必须是 Illuminate\Contracts\Auth\Authenticatable 的实例,给定 App\User 的实例,在 F:\eStore\vendor\laravel\framework\ 中调用第 385 行的 src\Illuminate\Auth\SessionGuard.php

【问题讨论】:

  • 嗨。请向我们展示您的 User.php 代码。
  • 您遇到的错误是什么,请发布错误

标签: laravel


【解决方案1】:

您需要将实现 \Illuminate\Contracts\Auth\Authenticatable 添加到您的 User 模型类定义中。

  class User extends Model implements \Illuminate\Contracts\Auth\Authenticatable {
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-22
    • 2021-10-19
    • 1970-01-01
    • 2020-05-27
    • 2020-02-04
    • 2020-07-11
    相关资源
    最近更新 更多