use version number in api endpoints
This commit is contained in:
parent
ccb3818da4
commit
36c6876d93
2 changed files with 33 additions and 27 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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']);
|
||||
});
|
||||
// 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']);
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue