Skip to content

hotfix for category obj #8

Merged
merged 1 commit into from
Feb 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions api/routes/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,20 @@
$q = new CategoryQuery;
$cats = $q::create()->find();





$response_json = [
"status" => [
"code" => $response->getStatusCode(),
"message" => "OK"
],
"data" => []
];
foreach( $cats as $cat ) {

foreach( $cats as $cat ) {
$rules = [];
$q = new CategoryRankNutrientQuery;
$requestedCatRules = $q->filterByCategoryId($cat->getId())->orderByRankId()->find();
foreach($requestedCatRules as $rule) {
$rules[$rule->getNutrient()->getName()][] = [
$rules[$rule->getRank()->getName()][] = [
"nutrientName" => $rule->getNutrient()->getName(),
"nutrientId" => $rule->getNutrient()->getId(),
"operator" => $rule->getOperator(),
Expand All @@ -40,9 +37,12 @@
"name" => $cat->getName(),
"rules" => $rules
];

}

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

});

/**
Expand Down