where('betradar_id', '>', 0)->pluck('betradar_id'); foreach ($res as $betradar_id) { Mapper::where('betradar_id', $betradar_id)->delete(); } if ($search_right) { return Mapper::query() ->where('starttime', '>', Carbon::now()) ->where('sport_id', $user->sport_id) ->where('provider_id', $user->provider_id) ->where(function ($query) use ($search_right) { foreach ($search_right as $value) { $query->orWhere('home', 'LIKE', '%'.$value.'%') ->orWhere('away', 'LIKE', '%'.$value.'%'); } }); } else { return Mapper::query() ->where('starttime', '>', Carbon::now()) ->where('sport_id', $user->sport_id) ->where('provider_id', $user->provider_id); } } }