where('betradar_id', '>', 0)->pluck('betradar_id'); foreach ($res as $betradar_id) { Mapper::where('betradar_id', $betradar_id)->delete(); } if (is_array($search_values) and \count($search_values)) { return Mapper::query() ->where('sport_id', auth()->user()->sport_id) ->where('provider_id', auth()->user()->provider_id) ->where(function ($query) use ($search_values) { foreach ($search_values as $value) { $query->orWhere('home', 'LIKE', '%'.$value.'%') ->orWhere('away', 'LIKE', '%'.$value.'%'); } }); } else { return Mapper::query() ->where('sport_id', auth()->user()->sport_id) ->where('provider_id', auth()->user()->provider_id); } } }