mirror of https://github.com/kcal-app/kcal.git
Allow all tags to be removed
This commit is contained in:
parent
be9c45a414
commit
8db02e302b
|
@ -104,9 +104,13 @@ class FoodController extends Controller
|
|||
$food->fill($attributes)->save();
|
||||
|
||||
// Sync tags.
|
||||
if ($tags = $request->get('tags')) {
|
||||
$tags = $request->get('tags');
|
||||
if (!empty($tags)) {
|
||||
$food->syncTags(explode(',', $tags));
|
||||
}
|
||||
elseif ($food->tags->isNotEmpty()) {
|
||||
$food->detachTags($food->tags);
|
||||
}
|
||||
|
||||
session()->flash('message', "Food {$food->name} updated!");
|
||||
return redirect()->route('foods.show', $food);
|
||||
|
|
|
@ -262,9 +262,13 @@ class RecipeController extends Controller
|
|||
}
|
||||
|
||||
// Sync tags.
|
||||
if ($tags = $request->get('tags')) {
|
||||
$tags = $request->get('tags');
|
||||
if (!empty($tags)) {
|
||||
$recipe->syncTags(explode(',', $tags));
|
||||
}
|
||||
elseif ($recipe->tags->isNotEmpty()) {
|
||||
$recipe->detachTags($recipe->tags);
|
||||
}
|
||||
|
||||
// Handle recipe image.
|
||||
if (!empty($input['image'])) {
|
||||
|
|
Loading…
Reference in New Issue