Ejemplo n.º 1
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());
     }
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 /**
  * Show countries list.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function countries()
 {
     $countries = Country::active()->orderBy('name', 'ASC')->get(['id', 'code', 'name', 'slug']);
     return response()->json(['countries' => $countries]);
 }