Laravel-参数1传递给Illuminate \ Auth \ EloquentUserProvider :: validateCredentials() [英] Laravel - Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials()

查看:91
本文介绍了Laravel-参数1传递给Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在laravel 5.6中使用了多重身份验证.

I use multi auth in laravel 5.6.

我使用linux 16.4.和PHP 7.2

I use linux 16.4. and PHP 7.2

运行 http://localhost:8000/manage/login 后,单击登录"按钮,显示此错误:

After run http://localhost:8000/manage/login and click login button, show this error:

"Type error: Argument 1 passed to Illuminate\Auth\EloquentUserProvider::validateCredentials() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\Admin given, called in /media/project/vendor/laravel/framework/src/Illuminate/Auth/SessionGuard.php on line 380"

如何发出此问题?

推荐答案

这仅表示您的 Admin 模型尚未实现 Authenticatable 接口.

It just means that your Admin model hasn't implemented the Authenticatable interface.

在您的班级中包含以下 use 语句,然后,例如

Include the following use statement in your class and then implement it e.g.

use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;

class Admin extends Model implements AuthenticatableContract {
    ...
}

然后,您需要确保模型中包含所有必需的方法.最简单的方法是包含 Authenticatable 特性,例如

You will then need to make sure that all of the necessary methods are included in your model. The easiest way to do this would be to include the Authenticatable trait e.g.

use Illuminate\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;

class Admin extends Model implements AuthenticatableContract {

    use Authenticatable;
}

最后,您可能需要重写某些方法,具体取决于您的数据库表是否与现成的 User 不同.

Lastly, you may need to override some of the methods depending on if you're db table is different from the out-of-the-box User.

这篇关于Laravel-参数1传递给Illuminate \ Auth \ EloquentUserProvider :: validateCredentials()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆