コード例 #1
0
 /**
  * Show regions list.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function regions($country_code)
 {
     $regions = Region::active()->orderBy('name', 'ASC')->whereHas('country', function ($query) {
         $query->active();
     })->where('country_code', $country_code)->get(['id', 'country_code', 'name', 'slug']);
     return response()->json(['regions' => $regions]);
 }
コード例 #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Country::create($this->country());
     Region::insert($this->regions());
     if ($this->cities() > 4000) {
         foreach (array_chunk($this->cities(), 3500) as $chunk) {
             City::insert($chunk);
         }
     } else {
         City::insert($this->cities());
     }
 }
コード例 #3
0
 /**
  * Check if country is already installed.
  *
  * @param  string $country
  * @return boolean
  */
 public static function installed($country)
 {
     $seeder = self::loadSeeder($country);
     $country = $seeder->country();
     if (Country::where('code', $country['code'])->count() > 0) {
         return true;
     }
     if (Region::where('country_code', $country['code'])->count() > 0) {
         return true;
     }
     if (City::where('country_code', $country['code'])->count() > 0) {
         return true;
     }
     return false;
 }