-
-
Save MPJHorner/5593c32a92f46f5d1bff9cf38eb34c7c to your computer and use it in GitHub Desktop.
Lumen Resource Routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); | |
function resource($uri, $controller) | |
{ | |
//$verbs = array('GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE'); | |
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