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 class ItemController extends Controller
{ {
public function showAllEvents() public function showAllItems()
{ {
return response()->json(Item::all()); 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)); 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' => 'api'], function () use ($router) {
$router->group(['prefix' => '1'], function () use ($router) {
// events // events
$router->get('events', ['uses' => 'EventController@showAllEvents']); $router->get('events', ['uses' => 'EventController@showAllEvents']);
$router->get('events/{id}', ['uses' => 'EventController@showOneEvent']); $router->get('event/{id}', ['uses' => 'EventController@showOneEvent']);
$router->post('events', ['uses' => 'EventController@create']); $router->post('event', ['uses' => 'EventController@create']);
$router->delete('events/{id}', ['uses' => 'EventController@delete']); $router->delete('event/{id}', ['uses' => 'EventController@delete']);
$router->put('events/{id}', ['uses' => 'EventController@update']); $router->put('event/{id}', ['uses' => 'EventController@update']);
});
$router->group(['prefix' => 'api'], function () use ($router) {
// containers // containers
$router->get('containers', ['uses' => 'ContainerController@showAllContainers']); $router->get('boxes', ['uses' => 'ContainerController@showAllContainers']);
$router->get('containers/{id}', ['uses' => 'ContainerController@showOneContainer']); $router->get('box/{id}', ['uses' => 'ContainerController@showOneContainer']);
$router->post('containers', ['uses' => 'ContainerController@create']); $router->post('box', ['uses' => 'ContainerController@create']);
$router->delete('containers/{id}', ['uses' => 'ContainerController@delete']); $router->delete('box/{id}', ['uses' => 'ContainerController@delete']);
$router->put('containers/{id}', ['uses' => 'ContainerController@update']); $router->put('box/{id}', ['uses' => 'ContainerController@update']);
});
$router->group(['prefix' => 'api'], function () use ($router) {
// items // items
$router->get('items', ['uses' => 'ItemController@showAllItems']); $router->get('items', ['uses' => 'ItemController@showAllItems']);
$router->get('items/{id}', ['uses' => 'ItemController@showOneItem']); $router->get('items/{query}', ['uses' => 'ItemController@searchAllItems']);
$router->post('items', ['uses' => 'ItemController@create']); $router->get('item/{id}', ['uses' => 'ItemController@showOneItem']);
$router->delete('items/{id}', ['uses' => 'ItemController@delete']); $router->post('item', ['uses' => 'ItemController@create']);
$router->put('items/{id}', ['uses' => 'ItemController@update']); $router->delete('item/{id}', ['uses' => 'ItemController@delete']);
$router->put('item/{id}', ['uses' => 'ItemController@update']);
});
}); });