Ejemplo n.º 1
0
 public static function getEn($array)
 {
     $output = '';
     if (!is_array($array)) {
         return $array;
     } else {
         if (array_key_exists('en', $array)) {
             $output = $array['en'];
         } elseif (is_array($array)) {
             foreach ($array as $key => $value) {
                 if (is_numeric($key) && array_key_exists('en', $value)) {
                     $output = Utils::getEn($value);
                 } elseif ($key == 'en') {
                     $output = $value;
                 }
             }
         }
     }
     return $output;
 }
 public static function allResourcePaginated($query, $index, $type = null)
 {
     $perPage = Request::input('perPage', 15);
     $from = $perPage * (Request::input('page', 1) - 1);
     $searchParams = array('body' => $query, 'size' => $perPage, 'from' => $from);
     $searchParams['index'] = $index;
     if ($type) {
         $searchParams['type'] = $type;
     }
     $client = self::getClient();
     $queryResponse = $client->search($searchParams);
     foreach ($queryResponse['hits']['hits'] as &$obj) {
         $obj['_source']['providerAcro'] = Utils::getProviderName($obj['_source']['providerId']);
     }
     $paginator = new LengthAwarePaginator($queryResponse['hits']['hits'], $queryResponse['hits']['total'], $perPage, Paginator::resolveCurrentPage(), ['path' => Paginator::resolveCurrentPath()]);
     return $paginator;
 }