您好,欢迎访问一九零五行业门户网

laravel控制器使用中间件

官方文档写的比较简单,只用如下就行了,但你使用过程中是会报错的,因为还没建立对应关系
public function __construct(){ $this->middleware('wechatapi');}
打开app/http/kernel.php
protected $routemiddleware = [ 'auth' => \app\http\middleware\authenticate::class, 'auth.basic' => \illuminate\auth\middleware\authenticatewithbasicauth::class, 'guest' => \app\http\middleware\redirectifauthenticated::class, 'throttle' => \illuminate\routing\middleware\throttlerequests::class, 'wechatapi'=>\app\http\middleware\wechatapi::class,];
其它类似信息

推荐信息