我正在向控制器发送带有 GET 方法的 ajax 请求
Route::get('test', ['Middleware' => 'TestFilter', 'uses' => 'HomeController@index']);
中间件:
public function handle($request, Closure $next)
{
return $next($request); //This does not seem to pass $request to HomeController
}
在 HomeController 的 index() 方法中,我试图返回 $request 但页面抛出错误
'Undefined variable: request' in D:\Apps\apilab\app\Http\Controllers\HomeController.php
我只是返回$request
HomeController
class HomeController extends Controller {
public function index() {
return $request;
}
}
如何将请求变量传递给 HomeController@index 以便我可以继续处理?我厌倦了尝试各种方法...