Support "servings" unit and require unit

This commit is contained in:
Christopher C. Wells 2021-01-27 08:46:12 -08:00
parent 0eae4af7d6
commit fc4e7a5fb5
4 changed files with 8 additions and 7 deletions

View File

@ -76,7 +76,7 @@ class JournalEntryController extends Controller
['value' => 'cup', 'label' => 'cup'],
['value' => 'oz', 'label' => 'oz'],
['value' => 'g', 'label' => 'grams'],
['value' => 'servings', 'label' => 'servings'],
['value' => 'serving', 'label' => 'servings'],
])
->with('default_date', Carbon::createFromFormat('Y-m-d', $date));
}
@ -94,7 +94,7 @@ class JournalEntryController extends Controller
['value' => 'cup', 'label' => 'cup'],
['value' => 'oz', 'label' => 'oz'],
['value' => 'g', 'label' => 'grams'],
['value' => 'servings', 'label' => 'servings'],
['value' => 'serving', 'label' => 'servings'],
]);
}
@ -111,7 +111,7 @@ class JournalEntryController extends Controller
'ingredients.amount' => ['required', 'array', new ArrayNotEmpty],
'ingredients.amount.*' => ['required_with:ingredients.id.*', 'nullable', new StringIsDecimalOrFraction],
'ingredients.unit' => ['required', 'array'],
'ingredients.unit.*' => ['nullable', 'string'],
'ingredients.unit.*' => ['required_with:ingredients.id.*'],
'ingredients.id' => ['required', 'array', new ArrayNotEmpty],
'ingredients.id.*' => 'required_with:ingredients.amount.*|nullable',
'ingredients.type' => ['required', 'array', new ArrayNotEmpty],

View File

@ -133,7 +133,8 @@ class RecipeController extends Controller
['value' => 'tbsp', 'label' => 'tbsp.'],
['value' => 'cup', 'label' => 'cup'],
['value' => 'oz', 'label' => 'oz'],
['value' => 'grams', 'label' => 'g'],
['value' => 'g', 'label' => 'grams'],
['value' => 'serving', 'label' => 'servings'],
]));
}
@ -157,7 +158,7 @@ class RecipeController extends Controller
'ingredients.amount' => ['required', 'array', new ArrayNotEmpty],
'ingredients.amount.*' => ['required_with:ingredients.id.*', 'nullable', new StringIsDecimalOrFraction],
'ingredients.unit' => ['required', 'array'],
'ingredients.unit.*' => 'nullable|string',
'ingredients.unit.*' => ['required_with:ingredients.id.*'],
'ingredients.detail' => ['required', 'array'],
'ingredients.detail.*' => 'nullable|string',
'ingredients.id' => ['required', 'array', new ArrayNotEmpty],

View File

@ -41,7 +41,7 @@
class="block w-full"
:options="$units"
:selectedValue="$unit ?? null">
<option value=""></option>
<option value="">Unit</option>
</x-inputs.select>
</div>
</div>

View File

@ -12,7 +12,7 @@
class="block"
:options="$ingredients_units"
:selectedValue="$unit ?? null">
<option value=""></option>
<option value="" selected>Unit</option>
</x-inputs.select>
<div class="w-full">
<x-ingredient-picker :default-id="$ingredient_id ?? null"