Endpoint for single component
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,5 +4,6 @@ Route::api(['version' => 'v1', 'prefix' => 'api'], function()
|
||||
{
|
||||
|
||||
Route::get('components', 'ApiController@getComponents');
|
||||
Route::get('components/{id}', 'ApiController@getComponent');
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user