orWhere('name', 'LIKE', '%'.$value.'%'); } })->pluck('id')->toArray(); $query = Event::query() ->with('home') ->with('away') ->where('sport_id', $sport_id) ->where('starttime', '>', Carbon::now()) ->where(function ($query) use ($element_ids) { $query->orWhereIn('home_id', $element_ids)->orWhereIn('away_id', $element_ids); }); } else { $query = Event::query() ->with('home') ->with('away') ->where('sport_id', $sport_id) ->where('betradar_id', 0) ->where('starttime', '>', Carbon::now()); } switch (Auth::user()->provider_id) { case 2: // BETSAPI return $query->where('betsapi_id', 0); default: return $query->with('event_bookmaker')->doesntHave('event_bookmaker'); break; } } }