2015-10-15 176 views
1

我知道如何在路由約束使用正則表達式,但我想用使用固定的值,而不是正則表達式是這樣的:路由參數在laravel 5.1

Route::get('{param}/delete/{id}',array(
    'as' => 'delete-post', 
    'uses' => '[email protected]' 
))->where(['param',['post','page'],'id'=>'[0-9]+']); 

當我嘗試這一點,我得到這樣的錯誤
Routing requirement for "param" must be a string.

我要的是param參數的值是固定的,它應該是postpage。那麼,我該如何達到上述目標呢?

回答

0

您可以使用正則表達式藏漢:

Route::get('{param}/delete/{id}',array(
    'as' => 'delete-post', 
    'uses' => '[email protected]' 
))->where(['param' => 'post|page', 'id'=>'[0-9]+']); 
+0

謝謝老兄,它解決的問題 – sixFingersMan