mirror of https://github.com/kcal-app/kcal.git
Enforce lower case for food and recipe names
This commit is contained in:
parent
e00373790d
commit
afe2bdafe0
|
@ -10,6 +10,7 @@ use Illuminate\Contracts\View\View;
|
||||||
use Illuminate\Http\RedirectResponse;
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class FoodController extends Controller
|
class FoodController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -83,6 +84,7 @@ class FoodController extends Controller
|
||||||
'protein' => 'nullable|numeric',
|
'protein' => 'nullable|numeric',
|
||||||
]);
|
]);
|
||||||
$attributes['serving_size'] = Number::floatFromString($attributes['serving_size']);
|
$attributes['serving_size'] = Number::floatFromString($attributes['serving_size']);
|
||||||
|
$attributes['name'] = Str::lower($attributes['name']);
|
||||||
$food->fill(array_filter($attributes))->save();
|
$food->fill(array_filter($attributes))->save();
|
||||||
return redirect(route('foods.show', $food))
|
return redirect(route('foods.show', $food))
|
||||||
->with('message', 'Changes saved!');
|
->with('message', 'Changes saved!');
|
||||||
|
|
|
@ -14,6 +14,7 @@ use Illuminate\Http\RedirectResponse;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class RecipeController extends Controller
|
class RecipeController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -116,7 +117,7 @@ class RecipeController extends Controller
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$recipe->fill([
|
$recipe->fill([
|
||||||
'name' => $input['name'],
|
'name' => Str::lower($input['name']),
|
||||||
'description' => $input['description'],
|
'description' => $input['description'],
|
||||||
'servings' => (int) $input['servings'],
|
'servings' => (int) $input['servings'],
|
||||||
]);
|
]);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd" />
|
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd" />
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<div class="text-2xl lowercase">
|
<div class="text-2xl">
|
||||||
{{ $food->name }}@if($food->detail), <span class="text-gray-500">{{ $food->detail }}</span>@endif
|
{{ $food->name }}@if($food->detail), <span class="text-gray-500">{{ $food->detail }}</span>@endif
|
||||||
</div>
|
</div>
|
||||||
@if($food->brand)
|
@if($food->brand)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd" />
|
<path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd" />
|
||||||
</svg>
|
</svg>
|
||||||
</a>
|
</a>
|
||||||
<div class="pb-2 lowercase flex justify-between items-baseline">
|
<div class="pb-2 flex justify-between items-baseline">
|
||||||
<div class="text-2xl">
|
<div class="text-2xl">
|
||||||
<a href="{{ route('recipes.show', $recipe) }}"
|
<a href="{{ route('recipes.show', $recipe) }}"
|
||||||
class="text-gray-600 hover:text-gray-800">{{ $recipe->name }}</a>
|
class="text-gray-600 hover:text-gray-800">{{ $recipe->name }}</a>
|
||||||
|
|
Loading…
Reference in New Issue