Skip to content

Instantly share code, notes, and snippets.

@meSingh
Created May 26, 2015 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meSingh/5ba67fdf2ea84a467c12 to your computer and use it in GitHub Desktop.
Save meSingh/5ba67fdf2ea84a467c12 to your computer and use it in GitHub Desktop.
Lumen Resource Routes
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
$app->get('/', function() use ($app) {
return $app->welcome();
});
resource('my', 'MyController');
/*
|--------------------------------------------------------------------------
| Resouce Routes
|--------------------------------------------------------------------------
*/
function resource($uri, $controller)
{
global $app;
$app->get( $uri, 'App\Http\Controllers\\'.$controller.'@index' );
$app->get( $uri.'/create', 'App\Http\Controllers\\'.$controller.'@create' );
$app->post( $uri, 'App\Http\Controllers\\'.$controller.'@store' );
$app->get( $uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@show' );
$app->get( $uri.'/{id}/edit', 'App\Http\Controllers\\'.$controller.'@edit' );
$app->put( $uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@update' );
$app->patch( $uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@update' );
$app->delete( $uri.'/{id}', 'App\Http\Controllers\\'.$controller.'@destroy' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment