Removed redundant items, upgraded to laravel 5.6
This commit is contained in:
@@ -3,12 +3,9 @@
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use App\Models\{Country,Currency};
|
||||
|
||||
class CreateTableCountries extends Migration
|
||||
{
|
||||
private $convert = 'App\Models\Old\Country';
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -16,7 +13,6 @@ class CreateTableCountries extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::dropIfExists('countries');
|
||||
Schema::create('countries', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name');
|
||||
@@ -27,24 +23,6 @@ class CreateTableCountries extends Migration
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user