where('sport_id', auth()->user()->sport_id) ->where('starttime', '>=', Carbon::now()) ->whereHas('event_bookmaker', function ($query) { $query->where('bookmaker_id', auth()->user()->bookmaker_id); }) ->get(); $event_ids = []; foreach ($events as $event) { if ($event->starttime != $event->event_bookmaker->starttime) { $event_ids[] = $event->id; } } return array_unique($event_ids); } }