Propaganistas
Propaganistas

Reputation: 1792

Laravel4: Change order of parameters when using Route::controller

If I have the following defined:

in app/routes.php

Route::controller('prefix', 'MyClass@getMethod')

in app/controllers/MyClass.php

class MyClass {
  public function getMethod($param) {
    // ...
  }
}

The route that will be available is /prefix/method/{param}.

Is it possible change this to /prefix/{param}/method without explicitly defining the route and thus just keeping Route::controller?

Note: the change of order can be applied to all methods of the class.

Thanks

Upvotes: 1

Views: 172

Answers (1)

Muharrem Tigdemir
Muharrem Tigdemir

Reputation: 198

Yes its possible to change order. Just edit the URI parameter at below

Your Routing :

Route::controller('prefix/{param}', 'MyController'); // Effects to All Controller Methods

OR

Route::controller('prefix/{param}', 'MyController@getMethod'); // Effects to specified Method

Keep the same controller. You don't need to change anyting.

The Result is /prefix/{param}/method

Upvotes: 1

Related Questions