From within Tinker I am trying to:
>>> Auth::loginUsingId(12);
=> false
>>> Auth::user();
=> null
>>> Auth::attempt(['email' => 'my@email.com']);
=> false
我猜,因为Auth通常使用会话数据,而会话可能不适用于tinker.
可以在Tinker内进行身份验证吗?
From within Tinker I am trying to:
>>> Auth::loginUsingId(12);
=> false
>>> Auth::user();
=> null
>>> Auth::attempt(['email' => 'my@email.com']);
=> false
我猜,因为Auth通常使用会话数据,而会话可能不适用于tinker.
可以在Tinker内进行身份验证吗?
It's possible to login in Tinker. For example:
auth()->loginUsingId(1)
auth()->id()
通常情况下,auth()->id()
的输出为1
.
如果对您无效,请确保storage
目录是可写的:
sudo chmod -R 755 storage
You're also doing it wrong when you're using the attempt()
method. The correct syntax is:
attempt(['email' => 'my@email.com', 'password' => 'secret'])