문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top