Skip to content

Commit

Permalink
savebatch prep work 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalisbury committed Apr 4, 2017
1 parent 2ffea19 commit 4fcf72d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions api/routes/rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,19 @@
});

$app->post('/rules/saveBatch/{catId}', function($request, $response) {
// $theRules = json_decode($request->getParam("batchObj"));
// $cat = $request->getAttribute('catId');
// foreach ($theRules as $r):
// $rule = new CategoryRankNutrient;
// $rule->findPk($r['ruleId'];
// $rule->setThreshold($r['threshold']);
// $rule->setUnits($r['units']));
// $rule->setOperator($r['operator']);
// $rule->setCategoryId($cat);
// $rule->setRankId($r['rankId']);
// $rule->setNutrientId($r['nutrientId']);
// $rule->save();
// endforeach;

echo $request->getBody();



$theRules = json_decode($request->getBody());
$cat = $request->getAttribute('catId');
foreach ($theRules as $r):
$rule = new CategoryRankNutrient;
$rule->findPk($r['ruleId'];
$rule->setThreshold($r['threshold']);
$rule->setUnits($r['units']));
$rule->setOperator($r['operator']);
$rule->setCategoryId($cat);
$rule->setRankId($r['rankId']);
$rule->setNutrientId($r['nutrientId']);
$rule->save();
endforeach;

});

0 comments on commit 4fcf72d

Please sign in to comment.