Skip to content

Commit

Permalink
Endpoint for single component
Browse files Browse the repository at this point in the history
  • Loading branch information
manavo committed Nov 24, 2014
1 parent 9f54629 commit 7e6f627
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ public function getComponents() {
return Component::all();
}

public function getComponent($id) {
$component = Component::find($id);
if ($component) {
return $component;
} else {
App::abort(404, 'Component not found');
}
}

}
1 change: 1 addition & 0 deletions app/routes/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
{

Route::get('components', 'ApiController@getComponents');
Route::get('components/{id}', 'ApiController@getComponent');

});

0 comments on commit 7e6f627

Please sign in to comment.