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 getCityCountries() { $var_cache = 'listCountriesCities'; if (!Cache::has($var_cache)) { $countries = FacebookCountry::whereSupportsCity('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); }