added percent in product price

This commit is contained in:
2026-07-04 18:00:57 +03:30
parent 4dea2fb212
commit 4ef0dfb2c0
7 changed files with 161 additions and 6 deletions
@@ -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);
}
});
}
};