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();
|
$food->fill(array_filter($attributes))->save();
|
||||||
|
|
||||||
// Sync tags.
|
// Sync tags.
|
||||||
$tags = explode(',', $request->get('tags'));
|
if ($tags = $request->get('tags')) {
|
||||||
$food->syncTags($tags);
|
$food->syncTags(explode(',', $tags));
|
||||||
|
}
|
||||||
|
|
||||||
session()->flash('message', "Food {$food->name} updated!");
|
session()->flash('message', "Food {$food->name} updated!");
|
||||||
return redirect()->route('foods.show', $food);
|
return redirect()->route('foods.show', $food);
|
||||||
|
|
|
||||||
|
|
@ -186,8 +186,9 @@ class RecipeController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Sync tags.
|
// Sync tags.
|
||||||
$tags = explode(',', $request->get('tags'));
|
if ($tags = $request->get('tags')) {
|
||||||
$recipe->syncTags($tags);
|
$recipe->syncTags(explode(',', $tags));
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::transaction(function () use ($recipe, $input) {
|
DB::transaction(function () use ($recipe, $input) {
|
||||||
|
|
|
||||||
|
|
@ -94,10 +94,10 @@
|
||||||
</div>
|
</div>
|
||||||
</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)
|
@foreach ($nutrients as $nutrient)
|
||||||
<!-- {{ ucfirst($nutrient) }} -->
|
<!-- {{ ucfirst($nutrient) }} -->
|
||||||
<div>
|
<div class="flex-auto">
|
||||||
<x-inputs.label for="{{ $nutrient }}"
|
<x-inputs.label for="{{ $nutrient }}"
|
||||||
:value="ucfirst($nutrient) . ' (g)'"/>
|
:value="ucfirst($nutrient) . ' (g)'"/>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,10 +48,10 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-auto">
|
<div class="flex flex-col md:flex-row">
|
||||||
@foreach (\App\Support\Nutrients::$all as $nutrient)
|
@foreach (\App\Support\Nutrients::$all as $nutrient)
|
||||||
<!-- {{ ucfirst($nutrient) }} -->
|
<!-- {{ ucfirst($nutrient) }} -->
|
||||||
<div>
|
<div class="flex-auto">
|
||||||
<x-inputs.label for="{{ $nutrient }}"
|
<x-inputs.label for="{{ $nutrient }}"
|
||||||
:value="ucfirst($nutrient) . ' (g)'"/>
|
:value="ucfirst($nutrient) . ' (g)'"/>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue