Mahmoud-Italy /
Lararoutes-lumen-custom-routes
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Lararoutes\Lumen; |
||
| 4 | |||
| 5 | class CustomRoutes |
||
| 6 | { |
||
| 7 | protected $app; |
||
| 8 | |||
| 9 | public function __construct($router='') |
||
| 10 | { |
||
| 11 | $this->app = $router; |
||
| 12 | } |
||
| 13 | |||
| 14 | function apiResource($uri, $controller) |
||
|
0 ignored issues
–
show
|
|||
| 15 | { |
||
| 16 | $this->app->get($uri, $controller.'@index'); |
||
| 17 | $this->app->post($uri, $controller.'@store'); |
||
| 18 | $this->app->get($uri.'/{id}', $controller.'@show'); |
||
| 19 | $this->app->put($uri.'/{id}', $controller.'@update'); |
||
| 20 | $this->app->delete($uri.'/{id}', $controller.'@destroy'); |
||
| 21 | |||
| 22 | // feel free to add more |
||
| 23 | } |
||
| 24 | |||
| 25 | |||
| 26 | function authResource($uri, $controller) |
||
|
0 ignored issues
–
show
|
|||
| 27 | { |
||
| 28 | $this->app->post($uri.'/register', $controller.'@register'); |
||
| 29 | $this->app->post($uri.'/login', $controller.'@login'); |
||
| 30 | $this->app->post($uri.'/logout', $controller.'@logout'); |
||
| 31 | $this->app->post($uri.'/refresh', $controller.'@refresh'); |
||
| 32 | $this->app->get($uri.'/me', $controller.'@me'); |
||
| 33 | |||
| 34 | // feel free to add more |
||
| 35 | } |
||
| 36 | } |
||
| 37 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.