【发布时间】:2016-03-09 01:09:35
【问题描述】:
以下是我在路由中直接调用控制器的路由。
如何将Request $request 传递给我的getBlog 函数.. 或者有什么方法可以直接在控制器的getblog 函数中获取$request 对象???
$artObj = App::make('App\Http\Controllers\Front\ArticleController');
return $artObj->getBlog($id);
路线中的代码:
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);
}
});
【问题讨论】: