官方文档写的比较简单,只用如下就行了,但你使用过程中是会报错的,因为还没建立对应关系
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,];