fix profit value after each order 2

This commit is contained in:
2026-07-18 17:37:41 +03:30
parent b66cd5e8f9
commit 285a159762
8 changed files with 512 additions and 25 deletions
@@ -0,0 +1,38 @@
<?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('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
if (! Schema::hasColumn('orders', 'product_id')) {
if (Schema::hasColumn('orders', 'customer_id')) {
$table->unsignedBigInteger('product_id')->nullable()->after('customer_id');
} else {
$table->unsignedBigInteger('product_id')->nullable();
}
}
});
}
public function down(): void
{
if (! Schema::hasTable('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
if (Schema::hasColumn('orders', 'product_id')) {
$table->dropColumn('product_id');
}
});
}
};
@@ -0,0 +1,42 @@
<?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('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
if (! Schema::hasColumn('orders', 'fee_source')) {
$table->string('fee_source', 32)->nullable()->after('total_fee');
}
if (! Schema::hasColumn('orders', 'fee_source_key')) {
$table->string('fee_source_key', 64)->nullable()->after('fee_source');
}
if (! Schema::hasColumn('orders', 'fee_source_label')) {
$table->string('fee_source_label', 255)->nullable()->after('fee_source_key');
}
});
}
public function down(): void
{
if (! Schema::hasTable('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
foreach (['fee_source_label', 'fee_source_key', 'fee_source'] as $col) {
if (Schema::hasColumn('orders', $col)) {
$table->dropColumn($col);
}
}
});
}
};
@@ -0,0 +1,34 @@
<?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('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
if (! Schema::hasColumn('orders', 'fee_breakdown')) {
$table->json('fee_breakdown')->nullable()->after('fee_source_label');
}
});
}
public function down(): void
{
if (! Schema::hasTable('orders')) {
return;
}
Schema::table('orders', function (Blueprint $table) {
if (Schema::hasColumn('orders', 'fee_breakdown')) {
$table->dropColumn('fee_breakdown');
}
});
}
};