Skip to content

Commit

Permalink
Merge pull request #12 from dmd-web-and-mobile/reversionapi
Browse files Browse the repository at this point in the history
reverting back
  • Loading branch information
jrs06005 committed Mar 3, 2017
2 parents 47a0365 + 7488ecd commit 15df02e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
22 changes: 12 additions & 10 deletions api/routes/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,29 @@
],
"data" => []
];

//[strtolower($rule->getRank()->getName())][$rule->getNutrient()->getName()]
foreach( $cats as $cat ) {
$rules = [];
$q = new CategoryRankNutrientQuery;
$requestedCatRules = $q->filterByCategoryId($cat->getId())->orderByRankId()->find();
$requestedCatRules = $q->filterByCategoryId($cat->getId())->orderByNutrientId()->find();
foreach($requestedCatRules as $rule) {
$rules[$rule->getNutrient()->getName()][] = [
"nutrientName" => $rule->getNutrient()->getName(),
"nutrientId" => $rule->getNutrient()->getId(),
"operator" => $rule->getOperator(),
"threshold" => $rule->getThreshold(),
"units" => $rule->getUnits(),
"rank" => $rule->getRankId()
$rules[] = [
"ruleId" => $rule->getId(),
"nutrientName" => $rule->getNutrient()->getName(),
"nutrientId" => $rule->getNutrient()->getId(),
"operator" => $rule->getOperator(),
"threshold" => $rule->getThreshold(),
"units" => $rule->getUnits(),
"rank" => $rule->getRankId(),
"categoryId" => $rule->getCategoryId()
];
}


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

}
Expand Down
4 changes: 3 additions & 1 deletion api/routes/rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@

foreach($requestedCatRules as $rule) {
$response_json["data"][] = [
"ruleId" => $rule->getId(),
"nutrientName" => $rule->getNutrient()->getName(),
"nutrientId" => $rule->getNutrient()->getId(),
"operator" => $rule->getOperator(),
"threshold" => $rule->getThreshold(),
"units" => $rule->getUnits(),
"rank" => $rule->getRankId()
"rank" => $rule->getRankId(),
"categoryId" => $rule->getCategoryId()
];
}

Expand Down

0 comments on commit 15df02e

Please sign in to comment.