Conditions | 2 |
Paths | 2 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | public function actionGetNutritionalInfo(): Response |
||
33 | { |
||
34 | $this->requireAcceptsJson(); |
||
35 | |||
36 | $ingredients = Craft::$app->getRequest()->getParam('ingredients'); |
||
37 | $serves = Craft::$app->getRequest()->getParam('serves'); |
||
38 | |||
39 | if (empty($ingredients)) { |
||
40 | return $this->asJson([ |
||
41 | 'error' => 'Please provide some ingredients first.', |
||
42 | ]); |
||
43 | } |
||
44 | |||
45 | $nutritionalInfo = Recipe::$plugin->nutritionApi->getNutritionalInfo($ingredients, $serves); |
||
46 | |||
47 | return $this->asJson($nutritionalInfo); |
||
48 | } |
||
50 |