Пример #1
0
 public function getTotalRegions($where)
 {
     $var_cache = 'total' . ucfirst($where) . 'FacebookRegions';
     if (!Cache::has($var_cache)) {
         switch ($where) {
             case 'world':
                 $data['total'] = FacebookRegion::count();
                 break;
             case 'hispanic':
                 $data['total'] = FacebookRegion::whereIdiom('es')->count();
                 break;
             default:
                 if (FacebookCountry::whereCode(strtolower($where))->first()) {
                     $data['total'] = FacebookRegion::whereCountryCode(strtoupper($where))->count();
                 } else {
                     return 'Invalid method';
                 }
         }
         Cache::put($var_cache, $data, 1440);
     }
     return Cache::get($var_cache);
 }
Пример #2
0
 public function getTotalRegions($where)
 {
     $where = strtolower($where);
     $var_cache = 'total' . ucfirst($where) . 'FacebookRegions';
     if (!Cache::has($var_cache)) {
         switch ($where) {
             case 'world':
                 $data['total'] = FacebookRegion::count();
                 break;
             case 'hispanic':
                 $data['total'] = FacebookRegion::whereIdiom('es')->count();
                 break;
             default:
                 $country_idiom = FacebookCountry::whereIdiom($where)->first();
                 if ($country_idiom) {
                     $data['total'] = FacebookRegion::whereIdiom($where)->count();
                 } else {
                     $country_search = FacebookCountry::whereCode(FacebookCountry::whereSlug($where)->first(['code'])->code)->first();
                     if ($country_search) {
                         $data['total'] = FacebookRegion::whereCountryCode($country_search->code)->count();
                     } else {
                         return 'Invalid method';
                     }
                 }
         }
         Cache::put($var_cache, $data, 1440);
     }
     return Cache::get($var_cache);
 }