Domanda

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

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top