mirror of https://github.com/kcal-app/kcal.git
Delete ingredient amounts on recipe delete
This commit is contained in:
parent
af65c5c7bb
commit
4b31f87f98
|
@ -273,10 +273,17 @@ class RecipeController extends Controller
|
||||||
*/
|
*/
|
||||||
public function destroy(Recipe $recipe): RedirectResponse
|
public function destroy(Recipe $recipe): RedirectResponse
|
||||||
{
|
{
|
||||||
// Remove the recipe from any recipes.
|
// Remove recipe ingredients.
|
||||||
foreach ($recipe->ingredientAmountRelationships as $ia) {
|
foreach ($recipe->ingredientAmounts as $ia) {
|
||||||
$ia->delete();
|
$ia->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove the recipe from any recipes.
|
||||||
|
foreach ($recipe->ingredientAmountRelationships as $iar) {
|
||||||
|
$iar->delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the recipe.
|
||||||
$recipe->delete();
|
$recipe->delete();
|
||||||
return redirect(route('recipes.index'))
|
return redirect(route('recipes.index'))
|
||||||
->with('message', "Recipe {$recipe->name} deleted!");
|
->with('message', "Recipe {$recipe->name} deleted!");
|
||||||
|
|
Loading…
Reference in New Issue