use version number in api endpoints

This commit is contained in:
j3d1 2019-11-30 13:47:54 +01:00
parent ccb3818da4
commit 36c6876d93
2 changed files with 33 additions and 27 deletions

View file

@ -8,12 +8,17 @@ use Illuminate\Http\Request;
class ItemController extends Controller
{
public function showAllEvents()
public function showAllItems()
{
return response()->json(Item::all());
}
public function showOneEvent($id)
public function searchAllItems()
{
return response()->json(Item::all()); //TODO actually search
}
public function showOneItem($id)
{
return response()->json(Item::find($id));
}

View file

@ -16,28 +16,29 @@ $router->get('/', function () use ($router) {
});
$router->group(['prefix' => 'api'], function () use ($router) {
$router->group(['prefix' => '1'], function () use ($router) {
// events
$router->get('events', ['uses' => 'EventController@showAllEvents']);
$router->get('events/{id}', ['uses' => 'EventController@showOneEvent']);
$router->post('events', ['uses' => 'EventController@create']);
$router->delete('events/{id}', ['uses' => 'EventController@delete']);
$router->put('events/{id}', ['uses' => 'EventController@update']);
});
$router->get('event/{id}', ['uses' => 'EventController@showOneEvent']);
$router->post('event', ['uses' => 'EventController@create']);
$router->delete('event/{id}', ['uses' => 'EventController@delete']);
$router->put('event/{id}', ['uses' => 'EventController@update']);
$router->group(['prefix' => 'api'], function () use ($router) {
// containers
$router->get('containers', ['uses' => 'ContainerController@showAllContainers']);
$router->get('containers/{id}', ['uses' => 'ContainerController@showOneContainer']);
$router->post('containers', ['uses' => 'ContainerController@create']);
$router->delete('containers/{id}', ['uses' => 'ContainerController@delete']);
$router->put('containers/{id}', ['uses' => 'ContainerController@update']);
});
$router->get('boxes', ['uses' => 'ContainerController@showAllContainers']);
$router->get('box/{id}', ['uses' => 'ContainerController@showOneContainer']);
$router->post('box', ['uses' => 'ContainerController@create']);
$router->delete('box/{id}', ['uses' => 'ContainerController@delete']);
$router->put('box/{id}', ['uses' => 'ContainerController@update']);
$router->group(['prefix' => 'api'], function () use ($router) {
// items
$router->get('items', ['uses' => 'ItemController@showAllItems']);
$router->get('items/{id}', ['uses' => 'ItemController@showOneItem']);
$router->post('items', ['uses' => 'ItemController@create']);
$router->delete('items/{id}', ['uses' => 'ItemController@delete']);
$router->put('items/{id}', ['uses' => 'ItemController@update']);
$router->get('items/{query}', ['uses' => 'ItemController@searchAllItems']);
$router->get('item/{id}', ['uses' => 'ItemController@showOneItem']);
$router->post('item', ['uses' => 'ItemController@create']);
$router->delete('item/{id}', ['uses' => 'ItemController@delete']);
$router->put('item/{id}', ['uses' => 'ItemController@update']);
});
});