如何在一个Route中的Laravel restful controller中处理指向同一方法的多个url

时间:2013-07-09 22:06:08

标签: php laravel laravel-4

我正在尝试一个安静的控制器,但是以这种方式绑定两个网址似乎不再起作用了。如何最好地处理?

// 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";
    }
}

1 个答案:

答案 0 :(得分:0)

Laravel4的解决方案归功于JasonLewis在Irc

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