Ensure NULL values are removed from attributes

This commit is contained in:
Christopher C. Wells 2021-05-30 12:52:07 -07:00
parent 8b9a947bb8
commit a7d96edd16
1 changed files with 3 additions and 1 deletions

View File

@ -277,7 +277,9 @@ class JournalEntryController extends Controller
*/
public function storeFromNutrients(StoreFromNutrientsJournalEntryRequest $request): RedirectResponse {
$attributes = $request->validated();
$entry = JournalEntry::make($attributes)->user()->associate(Auth::user());
$entry = JournalEntry::make(array_filter($attributes, function ($value) {
return !is_null($value);
}))->user()->associate(Auth::user());
$entry->save();
session()->flash('message', "Journal entry added!");
return redirect()->route(