added percent in product price
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('products')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
if (! Schema::hasColumn('products', 'cash_fee_buy_is_percent')) {
|
||||
if (Schema::hasColumn('products', 'cash_fee_buy')) {
|
||||
$table->boolean('cash_fee_buy_is_percent')->default(false)->after('cash_fee_buy');
|
||||
} else {
|
||||
$table->boolean('cash_fee_buy_is_percent')->default(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('products', 'cash_fee_sell_is_percent')) {
|
||||
if (Schema::hasColumn('products', 'cash_fee_sell')) {
|
||||
$table->boolean('cash_fee_sell_is_percent')->default(false)->after('cash_fee_sell');
|
||||
} else {
|
||||
$table->boolean('cash_fee_sell_is_percent')->default(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('products')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$drops = [];
|
||||
if (Schema::hasColumn('products', 'cash_fee_buy_is_percent')) {
|
||||
$drops[] = 'cash_fee_buy_is_percent';
|
||||
}
|
||||
if (Schema::hasColumn('products', 'cash_fee_sell_is_percent')) {
|
||||
$drops[] = 'cash_fee_sell_is_percent';
|
||||
}
|
||||
if ($drops !== []) {
|
||||
$table->dropColumn($drops);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user