mirror of https://github.com/kcal-app/kcal.git
Prevent exception on empty tags field
This commit is contained in:
parent
5bc1499e1a
commit
354e73ef67
|
@ -87,8 +87,9 @@ class FoodController extends Controller
|
|||
$food->fill(array_filter($attributes))->save();
|
||||
|
||||
// Sync tags.
|
||||
$tags = explode(',', $request->get('tags'));
|
||||
$food->syncTags($tags);
|
||||
if ($tags = $request->get('tags')) {
|
||||
$food->syncTags(explode(',', $tags));
|
||||
}
|
||||
|
||||
session()->flash('message', "Food {$food->name} updated!");
|
||||
return redirect()->route('foods.show', $food);
|
||||
|
|
|
@ -186,8 +186,9 @@ class RecipeController extends Controller
|
|||
]);
|
||||
|
||||
// Sync tags.
|
||||
$tags = explode(',', $request->get('tags'));
|
||||
$recipe->syncTags($tags);
|
||||
if ($tags = $request->get('tags')) {
|
||||
$recipe->syncTags(explode(',', $tags));
|
||||
}
|
||||
|
||||
try {
|
||||
DB::transaction(function () use ($recipe, $input) {
|
||||
|
|
|
@ -94,10 +94,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-rows-3 sm:grid-rows-3 md:grid-rows-2 lg:grid-rows-1 grid-flow-col">
|
||||
<div class="flex flex-col md:flex-row">
|
||||
@foreach ($nutrients as $nutrient)
|
||||
<!-- {{ ucfirst($nutrient) }} -->
|
||||
<div>
|
||||
<div class="flex-auto">
|
||||
<x-inputs.label for="{{ $nutrient }}"
|
||||
:value="ucfirst($nutrient) . ' (g)'"/>
|
||||
|
||||
|
|
|
@ -48,10 +48,10 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-auto">
|
||||
<div class="flex flex-col md:flex-row">
|
||||
@foreach (\App\Support\Nutrients::$all as $nutrient)
|
||||
<!-- {{ ucfirst($nutrient) }} -->
|
||||
<div>
|
||||
<div class="flex-auto">
|
||||
<x-inputs.label for="{{ $nutrient }}"
|
||||
:value="ucfirst($nutrient) . ' (g)'"/>
|
||||
|
||||
|
|
Loading…
Reference in New Issue