中间件,我们插件保持独立,位置保存在,例如Vote这个模块.
app/Plugin/Vote/Middleware/VoteTestMiddleware.php

<?php

namespace App\Plugin\Vote\Middleware;

use Closure;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\URL;

class VoteTestMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Closure $next
     * @return mixed
     */
    public function handle($request, Closure $next, $guard = null)
    {


        return $next($request);
    }
}

正确书写中间件文件即可。 最后一步也是需要附加到数组别名里面.例如文件
app/Plugin/Website/Kernel.php

<?php
// +----------------------------------------------------------------------
// | KongQiAdminBase [ Laravel快速后台开发 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2012~2019 http://www.kongqikeji.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: kongqi <531833998@qq.com>`
// +----------------------------------------------------------------------
//组不允许再定义web,api,就算添加也无效
return [
    "middlewareGroups" => [
    ],
    "routeMiddleware" => [
        'text' => App\Plugin\Vote\Middleware\VoteTestMiddleware::class,
    ]
];

然后中间件下调用和路由调用跟Laravel的中间件调用保持一样,准行Laravel设计思路。