public function getTotalProfile($idiom) { switch ($idiom) { case 'world': if (!Cache::has('totalWorldTwitterProfiles')) { $data = TwitterProfile::count(); Cache::put('totalWorldTwitterProfiles', $data, 1440); } return Cache::get('totalWorldTwitterProfiles'); break; case 'hispanic': if (!Cache::has('totalHispanicTwitterProfiles')) { $data = TwitterProfile::whereIdiom('es')->count(); Cache::put('totalHispanicTwitterProfiles', $data, 1440); } return Cache::get('totalHispanicTwitterProfiles'); break; } return 'Invalid method'; }
public function getTotalProfile($where) { $var_cache = 'total' . ucfirst($where) . 'TwitterProfiles'; if (!Cache::has($var_cache)) { switch ($where) { case 'world': $data['total'] = TwitterProfile::count(); break; case 'hispanic': $data['total'] = TwitterProfile::whereIdiom('es')->count(); break; default: $country_idiom = FacebookCountry::whereIdiom(strtolower($where))->first(); if ($country_idiom) { $data['total'] = TwitterProfile::whereIdiom(strtolower($where))->count(); } else { return 'Invalid method'; } } Cache::put($var_cache, $data, 1440); } return Cache::get($var_cache); }