我想做一些我不知道是否可行的事情。
这是我的 routes.php
Route::get('mockups/user/skills/{skill}', 'MockupsController@user');
Route::get('mockups/user/tours/{tour}', 'MockupsController@user');
Route::get('mockups/user', 'MockupsController@user');
和我的 MockupsController@user 函数
public function user($skill=null,$tour=null){
if($tour ==null && $skill != null)
return View::make('demo/mockups/user/public',array('skill'=>$skill));
if($tour!=null && $skill ==null)
return View::make('demo/mockups/user/public',array('tour'=>$tour));
return View::make('demo/mockups/user/public');
}
如果我得到/mockups/user/tours/tour1
url,控制器调用demo/mockups/user/public
视图而不发送$tour
变量。如何使它工作?
编辑
public function user($skill=null,$tour=null){
echo var_dump($skill);
echo var_dump($tour);
die();
if($tour ==null && $skill != null)
return View::make('demo/mockups/user/public',array('skill'=>$skill));
if($tour!=null && $skill ==null)
return View::make('demo/mockups/user/public',array('tour'=>$tour));
return View::make('demo/mockups/user/public');
}
显示
string(5) "tour1" NULL