Skip to content

Instantly share code, notes, and snippets.

@brunokunace
Created January 16, 2018 16:27
Show Gist options
  • Select an option

  • Save brunokunace/d91ed8e6c17e4cf9c11a852ff497e682 to your computer and use it in GitHub Desktop.

Select an option

Save brunokunace/d91ed8e6c17e4cf9c11a852ff497e682 to your computer and use it in GitHub Desktop.
<?php
use Illuminate\Http\Request;
$routeNames = [
'Category',
'Post',
'Contributor'
];
function routes($name)
{
return Route::group(['prefix' => $name, 'namespace' => "Api"], function () use ($name) {
Route::get('', [
'uses' => "{$name}Controller@index"
]);
Route::get('/{id}', [
'uses' => "{$name}Controller@get"
]);
Route::post('', [
'uses' => "{$name}Controller@post"
]);
Route::put('/{id}', [
'uses' => "{$name}Controller@put"
]);
Route::delete('/{id}', [
'uses' => "{$name}Controller@delete"
]);
});
}
array_map("routes", $routeNames);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment