Using morphTo() on services, added Ezypay payment Import

This commit is contained in:
Deon George
2019-06-07 16:54:27 +10:00
parent 41d6a07196
commit 253eb55c19
33 changed files with 11398 additions and 183 deletions

View File

@@ -0,0 +1,51 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddModelToService extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('ab_service', function (Blueprint $table) {
$table->string('model')->nullable();
});
// Go through our services and add the relation
foreach (\App\Models\Service\Adsl::all() as $o)
$this->update($o);
foreach (\App\Models\Service\Domain::all() as $o)
$this->update($o);
foreach (\App\Models\Service\Host::all() as $o)
$this->update($o);
foreach (\App\Models\Service\SSL::all() as $o)
$this->update($o);
foreach (\App\Models\Service\Voip::all() as $o)
$this->update($o);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('ab_service', function (Blueprint $table) {
$table->dropColumn('model');
});
}
function update(\Illuminate\Database\Eloquent\Model $o)
{
$oo = \App\Models\Service::findOrFail($o->service_id);
$oo->model = get_class($o);
$oo->save();
}
}