以下是我直接在路线中致电我的控制器的路线。
如何传递Request $request给我的getBlog函数。或者有什么方法可以直接$request在getblog控制器的函数中获取对象?
$artObj = App::make('App\Http\Controllers\Front\ArticleController');
return $artObj->getBlog($id);
Run Code Online (Sandbox Code Playgroud)
路线代码:
Route::get('/{slug}', function($slug) {
// Get Id and Type depending on url
$resultarray = App\Model\UrlAlias::getTypefromUrl($slug);
if(!empty($resultarray)) {
if($resultarray[0]['type'] == 'article') {
$id = $resultarray[0]['ref_id'] ;
$artObj = App::make('App\Http\Controllers\Front\ArticleController');
return $artObj->getBlog($id);
} else {
return Response::view("errors.404", $msg, 400);
}
} else {
return Response::view("errors.404", array(), 400);
}
});
Run Code Online (Sandbox Code Playgroud)