如何在一个Route中处理Laravel4restful控制器中指向同一方法的多个url


how to handle multiple urls pointing to same method in Laravel4 restful controller in one Route

我正在尝试一个restfull控制器,但以这种方式绑定两个url似乎不再有效。如何最好地处理?

// in the routes file
Route::get('/,new',array('as'=>'new_bit','uses'=>'BitsController@getNew'));
Route::controller('bits','BitsController');

// the controller
class BitsController extends BaseController {
    public $restful = true;
    /**
     * Display a listing of the resource.
     *
     * @return Response
     */
    public function getIndex()
    {
        return "this is the bits controller";
    }
    public function getNew()
    {
        return "this is the new page";
    }
}

由于JasonLewis在Irc 上提供了Laravel4的解决方案

Route::get('/{new?}', array('as' => 'new_bit', 'uses' => 'BitsController@getNew'))->where('new', 'new');