public function getCityCountries() { if (!Cache::has('listCountriesCities')) { $countries = FacebookCountry::whereSupportsCity('1')->orderBy('name', 'ASC')->get(['id_country', 'name', 'name_en', 'code', 'abbreviation']); $cache = array(); foreach ($countries as $value) { $index = $this->convert_string_to_url($value['name_en']); $cache[$index]['id'] = $value['id_country']; $cache[$index]['code'] = $value['code']; $cache[$index]['name'] = $value['name']; $cache[$index]['abbreviation'] = $value['abbreviation']; } Cache::put('listCountriesCities', $cache, 1440); } return Cache::get('listCountriesCities'); }
public function getRegionCountries() { $var_cache = 'listCountriesRegions'; if (!Cache::has($var_cache)) { $countries = FacebookCountry::whereSupportsRegion('1')->orderBy('name', 'ASC')->get(['id_country', 'name', 'slug', 'code', 'abbreviation']); $cache = array(); foreach ($countries as $value) { $index = $value['slug']; $cache[$index]['id'] = $value['id_country']; $cache[$index]['code'] = $value['code']; $cache[$index]['name'] = $value['name']; $cache[$index]['abbreviation'] = $value['abbreviation']; } Cache::put($var_cache, $cache, 1440); } return Cache::get($var_cache); }
public function getLastProfileAdded($idiom, $limit = 4) { $idiom = ucfirst($idiom); $var_cache = 'lastTwitterProfileAdded' . $idiom . $limit; if (!Cache::has($var_cache)) { $ranking = TwitterProfile::take($limit)->orderBy('id', 'DESC'); switch ($idiom) { case 'All': break; default: $country_idiom = FacebookCountry::whereIdiom(strtolower($idiom))->first(); if ($country_idiom) { $ranking->whereIdiom(strtolower($idiom)); } else { return 'Invalid method'; } } $ranking = $ranking->get(['screen_name', 'name', 'picture']); $pages = array(); foreach ($ranking as $key => $value) { $cache = NULL; $cache['screen_name'] = strtolower($value['screen_name']); $cache['name'] = $value['name']; $cache['picture'] = str_replace('_normal.', '.', $value['picture']); $pages[] = $cache; } Cache::put($var_cache, $pages, 1440); } return Cache::get($var_cache); }
public function getCountries() { // Cache::flush(); if (!Cache::has('listCountries')) { $countries = FacebookCountry::orderBy('name', 'ASC')->get(['id_country', 'name', 'code', 'abbreviation']); $cache = array(); foreach ($countries as $value) { $cache[strtolower($value['code'])]['id'] = $value['id_country']; $cache[strtolower($value['code'])]['name'] = $value['name']; $cache[strtolower($value['code'])]['abbreviation'] = $value['abbreviation']; } Cache::put('listCountries', $cache, 1440); } return Cache::get('listCountries'); }