diff --git a/app/Http/Controllers/JournalEntryController.php b/app/Http/Controllers/JournalEntryController.php index 3fd44cf..713574f 100644 --- a/app/Http/Controllers/JournalEntryController.php +++ b/app/Http/Controllers/JournalEntryController.php @@ -195,13 +195,22 @@ class JournalEntryController extends Controller } /** - * Remove the specified resource from storage. - * - * @param \App\Models\JournalEntry $journalEntry - * @return \Illuminate\Http\Response + * Confirm removal of the specified resource. */ - public function destroy(JournalEntry $journalEntry) + public function delete(JournalEntry $journalEntry): View { - // + return view('journal-entries.delete')->with('entry', $journalEntry); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(JournalEntry $journalEntry): RedirectResponse + { + $journalEntry->delete(); + session()->flash('message', 'Journal entry deleted!'); + return redirect(route('journal-entries.index', [ + 'date' => $journalEntry->date->toDateString() + ])); } } diff --git a/app/Support/Nutrients.php b/app/Support/Nutrients.php index 2689fd1..32c1e69 100644 --- a/app/Support/Nutrients.php +++ b/app/Support/Nutrients.php @@ -30,7 +30,11 @@ class Nutrients return $amount; } - if (empty($fromUnit) || $food->serving_unit === $fromUnit) { + if ( + empty($fromUnit) + || empty($food->serving_unit) + || $food->serving_unit === $fromUnit + ) { $multiplier = 1; } elseif ($fromUnit === 'tsp') { diff --git a/resources/views/foods/index.blade.php b/resources/views/foods/index.blade.php index 3bc61ad..9efca4d 100644 --- a/resources/views/foods/index.blade.php +++ b/resources/views/foods/index.blade.php @@ -12,9 +12,9 @@