public function getTotalPage($idiom) { switch ($idiom) { case 'world': if (!Cache::has('totalWorldFacebookPages')) { $data['total'] = FacebookPage::count(); Cache::put('totalWorldFacebookPages', $data, 1440); } return Cache::get('totalWorldFacebookPages'); break; case 'hispanic': if (!Cache::has('totalHispanicFacebookPages')) { $data['total'] = FacebookPage::whereIdiom('es')->count(); Cache::put('totalHispanicFacebookPages', $data, 1440); } return Cache::get('totalHispanicFacebookPages'); break; } return 'Invalid method'; }
public function getTotalPage($idiom) { $var_cache = 'total' . ucfirst($idiom) . 'FacebookPages'; if (!Cache::has($var_cache)) { switch ($idiom) { case 'world': $data['total'] = FacebookPage::count(); break; case 'hispanic': $data['total'] = FacebookPage::whereIdiom('es')->count(); break; default: if (FacebookCountry::whereCode(strtolower($idiom))->first()) { $data['total'] = FacebookPage::where('country_code', strtoupper($idiom))->count(); } else { return 'Invalid method'; } } Cache::put($var_cache, $data, 1440); } return Cache::get($var_cache); }