我需要获得' mp3'控制器中的价值!
(查看来自mp3s type
)的帖子
我的帖子类型: 视频,专辑,mp3
(web.php)
Route::group(array('prefix' => 'mp3s'), function($pt) {
Route::get("/", "PostController@archivePosts");
Route::get("mp3/{slug}", "PostController@singlePost");
});
Route::group(array('prefix' => 'albums'), function($pt) {
Route::get("/", "PostController@archivePosts");
Route::get("album/{slug}", "PostController@singlePost");
});
Route::group(array('prefix' => 'videos'), function($pt) {
Route::get("/", "PostController@archivePosts");
Route::get("video/{slug}", "PostController@singlePost");
});
答案 0 :(得分:1)
@danial dezfooli
要获取前缀值,您可以在控制器的方法中注入Request Dependency,如下所示。
public function index(\Illuminate\Http\Request $request){
dd($request->route()->getPrefix());
}
or you can do in another way also
public function index(){
dd($this->getRouter()->getCurrentRoute()->getPrefix());
}
答案 1 :(得分:-1)
Route::get("mp3/{slug}", "PostController@singlePost");
在PostController中,你可以像
那样得到它 public function singlePost($slug) {
dd($slug)// to check slug value
}