Richard
Richard

Reputation: 4546

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

I am trying out a restfull controller, but binding two urls this way does not seem to work anymore. How is this best handled?

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

Upvotes: 1

Views: 390

Answers (1)

Richard
Richard

Reputation: 4546

The solution for Laravel4 thanks to JasonLewis on Irc

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

Upvotes: 1

Related Questions