mirror of https://github.com/kcal-app/kcal.git
Sync tags _after_ saving recipe
This commit is contained in:
parent
d8ddaf611d
commit
fa3c1ee69e
|
@ -180,16 +180,9 @@ class RecipeController extends Controller
|
||||||
'servings' => (int) $input['servings'],
|
'servings' => (int) $input['servings'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Sync tags.
|
|
||||||
if ($tags = $request->get('tags')) {
|
|
||||||
$recipe->syncTags(explode(',', $tags));
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::transaction(function () use ($recipe, $input) {
|
DB::transaction(function () use ($recipe, $input) {
|
||||||
if (!$recipe->save()) {
|
$recipe->saveOrFail();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete any removed ingredients.
|
// Delete any removed ingredients.
|
||||||
$removed = array_diff($recipe->ingredientAmounts->keys()->all(), $input['ingredients']['original_key']);
|
$removed = array_diff($recipe->ingredientAmounts->keys()->all(), $input['ingredients']['original_key']);
|
||||||
|
@ -243,6 +236,11 @@ class RecipeController extends Controller
|
||||||
return back()->withInput()->withErrors($e->getMessage());
|
return back()->withInput()->withErrors($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync tags.
|
||||||
|
if ($tags = $request->get('tags')) {
|
||||||
|
$recipe->syncTags(explode(',', $tags));
|
||||||
|
}
|
||||||
|
|
||||||
session()->flash('message', "Recipe {$recipe->name} updated!");
|
session()->flash('message', "Recipe {$recipe->name} updated!");
|
||||||
return redirect()->route('recipes.show', $recipe);
|
return redirect()->route('recipes.show', $recipe);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue