我制作了一个自定义防护实现,强制禁用"记住我"。除了这个自定义实现的细节 - 当我尝试将它绑定到Guard Contract时,似乎出现了问题。
Customguard.php
<?php
namespace App\Contracts\Auth;
use Illuminate\Auth\Guard as StockGuard;
use Illuminate\Contracts\Auth\Authenticatable as UserContract;
use Illuminate\Contracts\Auth\Guard as GuardContract;
class CustomGuard extends StockGuard implements GuardContract
{
/**
* Log a user into the application.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param bool $remember
* @return void
*/
public function login (UserContract $user, $remember = false)
{
parent::login($user, false);
}
}
(使用完全相同的方法签名覆盖Guard->login
)
我在boot
app/Providers/AuthServiceProvider.php
方法中按如下方式进行了绑定
$this->app->bind('Illuminate\Contracts\Auth\Guard', App\Contracts\Auth\CustomGuard::class);
一切正常,直到调用CustomGuard-&gt;登录。
BindingResolutionException in Container.php line 749:
Target [Illuminate\Contracts\Auth\UserProvider] is not instantiable.
我做错了什么?