laravel 控制器中,在中间件加载完后触发逻辑
<?php
namespace ...\Controllers;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
class XxxController extends Controller
{
public function __construct(Request $request)
{
$this->middleware(function ($request, $next) {
// 中间件加载完毕
$this->init();
//
return $next($request);
});
}
private function init()
{
// 中间件已经加载完毕,做点什么吧!
}
}