Endpoint for single component

This commit is contained in:
manavo
2014-11-24 18:03:55 +00:00
parent 9f54629359
commit 7e6f62702f
2 changed files with 10 additions and 0 deletions

View File

@@ -6,4 +6,13 @@ class ApiController extends Dingo\Api\Routing\Controller{
return Component::all();
}
public function getComponent($id) {
$component = Component::find($id);
if ($component) {
return $component;
} else {
App::abort(404, 'Component not found');
}
}
}

View File

@@ -4,5 +4,6 @@ Route::api(['version' => 'v1', 'prefix' => 'api'], function()
{
Route::get('components', 'ApiController@getComponents');
Route::get('components/{id}', 'ApiController@getComponent');
});