public function getTotalCities($where) { $var_cache = 'total' . ucfirst($where) . 'FacebookCities'; if (!Cache::has($var_cache)) { switch ($where) { case 'world': $data['total'] = FacebookCity::count(); break; case 'hispanic': $data['total'] = FacebookCity::whereIdiom('es')->count(); break; default: if (FacebookCountry::whereCode(strtolower($where))->first()) { $data['total'] = FacebookCity::whereCountryCode(strtoupper($where))->count(); } else { return 'Invalid method'; } } Cache::put($var_cache, $data, 1440); } return Cache::get($var_cache); }
public function getTotalCities($where) { $where = strtolower($where); $var_cache = 'total' . ucfirst($where) . 'FacebookCities'; if (!Cache::has($var_cache)) { switch ($where) { case 'world': $data['total'] = FacebookCity::count(); break; case 'hispanic': $data['total'] = FacebookCity::whereIdiom('es')->count(); break; default: $country_idiom = FacebookCountry::whereIdiom($where)->first(); if ($country_idiom) { $data['total'] = FacebookCity::whereIdiom($where)->count(); } else { $country_search = FacebookCountry::whereCode(FacebookCountry::whereSlug($where)->first(['code'])->code)->first(); if ($country_search) { $data['total'] = FacebookCity::whereCountryCode($country_search->code)->count(); } else { return 'Invalid method'; } } } Cache::put($var_cache, $data, 1440); } return Cache::get($var_cache); }