Fixed meal plan did not load when a containing recipe was deleted (closes #361)

This commit is contained in:
Bernd Bestel
2019-09-21 09:18:40 +02:00
parent ab44566890
commit 327c1f4fb3
4 changed files with 24 additions and 2 deletions

View File

@@ -135,12 +135,19 @@ class RecipesController extends BaseController
$events = array();
foreach($this->Database->meal_plan() as $mealPlanEntry)
{
$recipe = FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id']);
$title = '';
if ($recipe !== null)
{
$title = $recipe->name;
}
$events[] = array(
'id' => $mealPlanEntry['id'],
'title' => FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id'])->name,
'title' => $title,
'start' => $mealPlanEntry['day'],
'date_format' => 'date',
'recipe' => json_encode(FindObjectInArrayByPropertyValue($recipes, 'id', $mealPlanEntry['recipe_id'])),
'recipe' => json_encode($recipe),
'mealPlanEntry' => json_encode($mealPlanEntry)
);
}