increments('id'); $table->string('name'); $table->string('twocode',2)->nullable(); $table->string('threecode',3); $table->integer('currency_id')->unsigned()->nullable(); $table->boolean('active'); $table->foreign('currency_id')->references('id')->on('currencies'); }); if ($this->convert) foreach (($this->convert)::all() as $o) { if ($o->currency) $co = Currency::where('name',$o->currency->name)->firstOrFail(); $oo = new Country; $oo->name = $o->name; $oo->twocode = $o->two_code; $oo->threecode = $o->three_code; $oo->active = $o->three_code == 'AUS' ? TRUE : FALSE; if ($o->currency) $co->countries()->save($oo); else $oo->save(); } } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('countries'); } }