diff --git a/app/Http/Controllers/ItemController.php b/app/Http/Controllers/ItemController.php index d12c543..1e7105a 100644 --- a/app/Http/Controllers/ItemController.php +++ b/app/Http/Controllers/ItemController.php @@ -8,18 +8,23 @@ 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)); } public function create(Request $request) - { + { $item = Item::create($request->all()); return response()->json($item, 201); } @@ -37,4 +42,4 @@ class ItemController extends Controller Item::findOrFail($id)->delete(); return response('Deleted Successfully', 200); } -} \ No newline at end of file +} diff --git a/routes/web.php b/routes/web.php index 641e9a7..177b3b0 100644 --- a/routes/web.php +++ b/routes/web.php @@ -16,28 +16,29 @@ $router->get('/', function () use ($router) { }); $router->group(['prefix' => 'api'], 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->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->group(['prefix' => '1'], function () use ($router) { + // events + $router->get('events', ['uses' => 'EventController@showAllEvents']); + $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) { - // 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']); -}); \ No newline at end of file + // containers + $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']); + + // items + $router->get('items', ['uses' => 'ItemController@showAllItems']); + $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']); + }); + +});