Skip to content

Commit

Permalink
Update ShoppingListsController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
aquzif committed Feb 5, 2024
1 parent e7f5a0b commit cbb93a7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Http/Controllers/ShoppingListsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ public function index(Request $request) {

public function insertCalendarEntries(ShoppingList $shoppingList, Request $request) {
$fields = $request->validate([
'entries_ids' => 'required|string',
'date_from' => 'required|date',
'date_to' => 'required|date'
]);


$fields['entries_ids'] = explode(',', $fields['entries_ids']);

$calendarEntries =
$request->user()->calendarEntries()
->whereBetween('date', [$fields['date_from'], $fields['date_to']])
->whereIn('id', $fields['entries_ids'])
->orderBy('date')
->get();

Expand All @@ -36,6 +39,7 @@ public function insertCalendarEntries(ShoppingList $shoppingList, Request $reque

$shoppingListEntriesToInsert = [];


foreach ($calendarEntries as $calendarEntry) {
$ingredients = $calendarEntry->recipe->ingredients()->get();

Expand Down

0 comments on commit cbb93a7

Please sign in to comment.