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); }