Skip to content

Commit

Permalink
working with no confirmation doe
Browse files Browse the repository at this point in the history
  • Loading branch information
jsalisbury committed Apr 4, 2017
1 parent d7b5c1f commit a96cdcd
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions api/routes/rules.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,25 @@

$app->post('/rules/saveBatch/{catId}', function($request, $response) {

// $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;

$theRules = json_decode($request->getBody());
// print_r($theRules);

$cat = $request->getAttribute('catId');
foreach ($theRules as $r):

if ($r->ruleId != 0)
$rule = CategoryRankNutrientQuery::create()->findPk($r->ruleId);
else
$rule = new CategoryRankNutrient;


$rule->setThreshold($r->threshold);
$rule->setUnits($r->units);
$rule->setOperator($r->operator);
$rule->setCategoryId($cat);
$rule->setRankId($r->rank);
$rule->setNutrientId($r->nutrientId);
$rule->save();
endforeach;

});

0 comments on commit a96cdcd

Please sign in to comment.