0
我有一個可選的參數,這條路線:Laravel 4命名路由可選PARAMATERS
Route::get('{id}/results/subject/{subject_id}/{step_id?}', array('as' =>'test', 'uses' => '\Controllers\[email protected]'));
,我得到這個在我的TestController
function Show($id, $subject_id, $step_id){
//Some stuff
}
我想一個默認值屬性我選step_id
參數就像here。如果我沒有給出一個默認值,我的控制器就會失去一個參數錯誤。
我已經試過
Route::get('{id}/results/subject/{subject_id}/{step_id?}', array('as' =>'test', 'uses' => '\Controllers\[email protected]', function($step_id = '3'){return $step_id});
和
Route::get('{id}/results/subject/{subject_id}/{step_id?}',function($step_id = '3'){return $step_id}, array('as' =>'test', 'uses' => '\Controllers\[email protected]'));
但兩者都沒有工作。
謝謝。我將在10分鐘內接受。 – Wistar