Skip to content

Commit

Permalink
get category by id
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalisbury committed Nov 16, 2016
1 parent 5002fc2 commit 9b19ac1
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions api/routes/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@
"name" => $cat->getName()
];
}
$response = $response->withJSON($response_json);
return $response;
});

/**
* GET Category by ID
* @param id int PK of known category
*/

$app->get('/category/{id}', function( $request, $response ) {
$q = new CategoryQuery;
$cat = $q->findPK($request->getAttribute('id'));

$response_json = [
"status" => [
"code" => $response->getStatusCode(),
"message" => "OK"
],
"data" => []
];

$response_json["data"][] = [
"id" => $cat->getId(),
"name" => $cat->getName()
];

$response = $response->withJSON($response_json);
return $response;
});

0 comments on commit 9b19ac1

Please sign in to comment.