From d7a30e92992cbf951423e384efc0b946c8f15173 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sat, 3 Aug 2024 09:44:44 +0200 Subject: [PATCH] fix: api sort events by first and only from today --- app/Http/Controllers/API/EventController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/API/EventController.php b/app/Http/Controllers/API/EventController.php index a6c5313..44d7750 100644 --- a/app/Http/Controllers/API/EventController.php +++ b/app/Http/Controllers/API/EventController.php @@ -19,8 +19,11 @@ public function index(Calendar $calendar) { $events = $calendar ->events() + ->where('start_date', '>=', Carbon::today()) + ->orderBy('start_date', 'asc') ->get(); + // Set the full path on the image attribute and add a full url to event $events->transform(function ($event) { $event->image = isset($event->image) ? asset('storage/banners/' . $event->image) : null;