laravel控制器使用中间件


官方文档写的比较简单,只用以下就好了,但你使用过程当中是会报错的,由于还没创建对应关系php

public function __construct(){
    $this->middleware('wechatapi');
}

打开app/Http/Kernel.phpapi

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,
];
相关文章
相关标签/搜索