针对用户和管理员的Laravel 5多重身份验证
我正在尝试为用户和管理员创建多重身份验证。所以我已经为管理员创建了单独的中间件,它实现了siteguard契约,它是guard契约的一个子契约。但我明白了针对用户和管理员的Laravel 5多重身份验证,laravel,Laravel,我正在尝试为用户和管理员创建多重身份验证。所以我已经为管理员创建了单独的中间件,它实现了siteguard契约,它是guard契约的一个子契约。但我明白了 传递给App\Http\Middleware\AdminAuthenticate::\uuu construct()的参数1必须实现接口Illumb\Contracts\Auth\SiteGuard,给定Illumb\Auth\Guard的实例 这个错误请帮忙解决 <?php namespace App\Http\Middleware
传递给App\Http\Middleware\AdminAuthenticate::\uuu construct()的参数1必须实现接口Illumb\Contracts\Auth\SiteGuard,给定Illumb\Auth\Guard的实例 这个错误请帮忙解决
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Contracts\Auth\SiteGuard as Guard_;
class AdminAuthenticate
{
/**
* The Guard implementation.
*
* @var Guard_
*/
protected $adminauth;
/**
* Create a new filter instance.
*
* @param Guard_ $adminauth
* @return void
*/
public function __construct(Guard_ $adminauth)
{
$this->adminauth = $adminauth;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($this->adminauth->guest()) {
if ($request->ajax()) {
return response('Unauthorized.', 401);
} else {
return redirect()->guest('/base');
}
}
return $next($request);
}
}
必须实现接口什么?是的,请编辑您的问题并完成错误中缺少的部分。传递给App\Http\Middleware\AdminAuthenticate::\uu\u construct()的参数1必须实现接口illumb\Contracts\Auth\SiteGuard,实例illumb\Auth\Guard givenc您可以演示如何使用中间件吗
。它是在控制器
中还是在路线
上?您的代码中是否有意在Guard\uuuuuuu末尾加下划线?