app\models\Beatmapset::search PHP Method

    public static function search(array $params = [])
    {
        // default search params
        $params += ['query' => null, 'mode' => null, 'status' => 0, 'genre' => null, 'language' => null, 'extra' => null, 'rank' => [], 'page' => 1, 'sort' => ['ranked', 'desc']];
        self::sanitizeSearchParams($params);
        if (empty(config('elasticsearch.hosts'))) {
            $beatmap_ids = self::searchDB($params);
        } else {
            $beatmap_ids = self::searchES($params);
        }
        $beatmaps = [];
        if (count($beatmap_ids) > 0) {
            $ids = implode(',', $beatmap_ids);
            $beatmaps = static::with('beatmaps')->whereIn('beatmapset_id', $beatmap_ids)->orderByRaw(DB::raw("FIELD(beatmapset_id, {$ids})"))->get();
        }
        return $beatmaps;
    }

Usage Example

 public function search()
 {
     $current_user = Auth::user();
     $params = [];
     if (is_null($current_user)) {
         $params = ['page' => Request::input('page')];
     } else {
         $params = ['query' => Request::input('q'), 'mode' => Request::input('m'), 'status' => Request::input('s'), 'genre' => Request::input('g'), 'language' => Request::input('l'), 'extra' => array_filter(explode('-', Request::input('e')), 'strlen'), 'rank' => array_filter(explode('-', Request::input('r')), 'strlen'), 'page' => Request::input('page'), 'sort' => explode('_', Request::input('sort'))];
         if (!$current_user->isSupporter()) {
             unset($params['rank']);
         }
     }
     $params = array_filter($params, function ($v, $k) {
         if (is_array($v)) {
             return !empty($v);
         } else {
             return presence($v) !== null;
         }
     }, ARRAY_FILTER_USE_BOTH);
     $beatmaps = Beatmapset::search($params);
     return json_collection($beatmaps, new BeatmapsetTransformer(), 'beatmaps');
 }