예제 #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('Countries')->delete();
     Country::create(['id' => 1, 'country_name' => 'Lithuania']);
     Country::create(['id' => 2, 'country_name' => 'Russia']);
     Country::create(['id' => 3, 'country_name' => 'Germany']);
 }
예제 #2
0
 public function run()
 {
     DB::table('users')->delete();
     $VK = new VK(env('VK_APP_ID'), env('VK_KEY_SECRET'));
     $vkCountries = $VK->api('database.getCountries', ['need_all' => 1, 'count' => 1000, 'lang' => 'ru']);
     foreach ($vkCountries['response'] as $country) {
         Country::create(['id' => $country['cid'], 'title' => $country['title']]);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $this->command->info('Start country seeder!');
     $countries = $this->getCountryArray();
     foreach ($countries as $code => $name) {
         Country::create(['name' => $name, 'code' => $code]);
     }
     $this->command->info('Country table seeded!');
 }
예제 #4
0
 private static function createStartingCountries(Field $field)
 {
     $countries = new Collection();
     for ($x = 0; $x < \Config::get('settings.fieldWidth'); $x++) {
         for ($y = 0; $y < \Config::get('settings.fieldHeight'); $y++) {
             $countries->push(Country::create(['x' => $x, 'y' => $y, 'field_id' => $field->id]));
         }
     }
     return $countries;
 }
예제 #5
0
 public function update($id)
 {
     // save updated
     $record = $this->records->find($id);
     if (!$record) {
         Country::create(Input::all());
         return $this->respond($record);
     }
     $record->fill(Input::all())->save();
     return $this->respond($record);
 }
예제 #6
0
 /**
  * Execute the job.
  *
  * @param Country $country
  */
 public function handle(Country $country)
 {
     /**
      * Save all Countries
      */
     $this->countries->transform(function ($name, $code) use($country) {
         return $country->create(compact('name', 'code'));
     });
     /**
      * Announce CountryWasCreated
      */
     event(new CountryWasCreated($this->countries->toArray()));
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('country', function (Blueprint $table) {
         $table->engine = 'InnoDB';
         $table->string('code', 2)->primary()->unique();
         $table->string('name')->index();
         $table->string('local_name')->index();
         $table->timestamps();
     });
     // FIXTURES EU Countries
     $data = [];
     $file = file_get_contents(base_path() . '/database/fixtures/countries.csv');
     $lines = str_getcsv($file, "\n");
     foreach ($lines as $line) {
         $keys = ['local_name', 'name', 'code'];
         $row = array_combine($keys, str_getcsv($line, ';'));
         Country::create($row);
     }
 }
예제 #8
0
  public function run ()
  {
  
    DB::table('countries')->delete();

    Country::create([

      'cname' => '中国',

      'ename' => 'China',

      'code' => 1,

      'active' => 1

    ]);
  
  
  }