- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Laravel 的初学者。
我想使用:
Auth::login(users::find(1))
结果:输入错误:
Argument 1 passed to Illuminate\Auth\SessionGuard::login() must be an instance of Illuminate\Contracts\Auth\Authenticatable, instance of App\users given
我更改了模型以扩展 Authenticatable 而不是 Model。此外,我将 Auth 语句更改为:
Auth::login(users::where('id', 1))
结果:输入错误:
Argument 1 passed to Illuminate\Auth\SessionGuard::login() must implement interface Illuminate\Contracts\Auth\Authenticatable, instance of Illuminate\Database\Eloquent\Builder given
不知道你是否愿意帮助我,'感谢'
最佳答案
你应该在用户模型类中实现 Illuminate\Contracts\Auth\Authenticatable 以通过 Auth::login
Authenticate A User Instance
If you need to log an existing user instance into your application, you may call the login method with the user instance. The given object must be an implementation of the Illuminate\Contracts\Auth\Authenticatable contract. Of course, the App\User model included with Laravel already implements this interface:
Auth::login($user);
https://laravel.com/docs/5.1/authentication
或者你可以简单地这样做:
Auth::loginUsingId(1);
关于Laravel 身份验证令人困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35604385/
很抱歉新手的问题,但是: 我最近才发现“=”运算符不只是处理对象/等等。值(value),也是引用。这很酷,但我认为这对变量来说是不一样的,它不会在存储整数或 float 的变量之间创建引用。后来我觉
我是一名优秀的程序员,十分优秀!