/** * Run the database seeds. * * @return void */ public function run() { // // Create all of the address types // /** @var Keytype $keytype */ $keytype = Keytype::create(['name' => 'address-types', 'description' => 'Address Types']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'billing', 'keyname' => 'Billing Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'shipping', 'keyname' => 'Shipping Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'contact', 'keyname' => 'Contact Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'office', 'keyname' => 'Office Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'home', 'keyname' => 'Home Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'head-office', 'keyname' => 'Head Office Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'branch-office', 'keyname' => 'Branch Office Address']); // // Create all of the address statuses // /** @var Keytype $keytype */ $keytype = Keytype::create(['name' => 'address-statuses', 'description' => 'Address Statuses']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'current', 'keyname' => 'Current Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'previous', 'keyname' => 'Previous Address']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'future', 'keyname' => 'Future Address']); // // Name ordering rules // See https://en.wikipedia.org/wiki/Alphabetical_order#Ordering_by_surname // /** @var Keytype $keytype */ $keytype = Keytype::create(['name' => 'name-order', 'description' => 'Name Ordering Rules']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'en', 'keyname' => 'English Convention: Smith, John']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'nl', 'keyname' => 'Dutch/German/South African style: Merwe van der, Joost']); Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => 'cn', 'keyname' => 'China/Vietnam/Korea style: Park Geun-hye']); }
/** * Execute the console command. * * @return mixed */ public function handle() { /** @var Keytype $keytype */ $keytype = Keytype::create(['name' => 'countries', 'description' => 'ISO 3166 Country Codes', 'created_by' => 'loader', 'updated_by' => 'loader']); $handle = fopen($this->filename, 'r'); // Get this in advance by calling wc -l $file $count = 246; $bar = $this->output->createProgressBar($count); while ($data = fgetcsv($handle)) { try { list($country_code, $country_name) = $data; } catch (\Exception $e) { continue; } // progress advance $bar->advance(); // Skip the first line if ($country_code == "country_code") { continue; } // Create the entry Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => $country_code, 'keyname' => $country_name, 'created_by' => 'loader', 'updated_by' => 'loader']); } fclose($handle); $bar->finish(); $this->output->writeln('Finished'); }
/** * Execute the console command. * * @return mixed */ public function handle() { /** @var Keytype $keytype */ $keytype = Keytype::create(['name' => 'timezones', 'description' => 'Time Zones', 'created_by' => 'loader', 'updated_by' => 'loader']); // Get this in advance $count = 417; $bar = $this->output->createProgressBar($count); $timezone_list = timezone_identifiers_list(); foreach ($timezone_list as $timezone) { // Create the entry Keyvalue::create(['keytype_id' => $keytype->id, 'keyvalue' => $timezone, 'keyname' => $timezone, 'created_by' => 'loader', 'updated_by' => 'loader']); // progress advance $bar->advance(); } // Finished $bar->finish(); $this->output->writeln('Finished'); }