Wallet operations

This commit is contained in:
Fairuz
2021-10-07 01:34:11 +08:00
parent dbfe8751d6
commit e94ef44928
31 changed files with 1027 additions and 29 deletions
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class DropWalletTransactionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::dropIfExists('wallet_transaction');
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AlterWalletCompanyId extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (Schema::hasColumn('wallets', 'company_id')) {
Schema::table('wallets', function (Blueprint $table) {
$table->dropForeign('wallets_company_id_foreign');
$table->dropColumn('company_id');
});
}
if (!Schema::hasColumn('wallets', 'owner_id')) {
Schema::table('wallets', function (Blueprint $table) {
$table->morphs('owner');
});
//In-case the model name lengthy
Schema::table('wallets', function (Blueprint $table) {
$table->string('owner_type', 250)->change();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}
@@ -0,0 +1,45 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
class AlterTransactionBookingId extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if (!Schema::hasColumn('transactions', 'owner_id')) {
Schema::table('transactions', function (Blueprint $table) {
$table->morphs('owner');
});
//In-case the model name lengthy
Schema::table('transactions', function (Blueprint $table) {
$table->string('owner_type', 250)->change();
});
DB::statement("UPDATE transactions SET owner_type='App\\\\Models\\\\Booking', owner_id = booking_id");
Schema::table('transactions', function (Blueprint $table) {
$table->dropForeign('transactions_booking_id_foreign');
//$table->dropColumn('booking_id');
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}