fix bug of pargar

This commit is contained in:
2026-07-26 14:15:26 +03:30
parent 667e3736fb
commit 06b3113b98
17 changed files with 561 additions and 26 deletions
@@ -0,0 +1,47 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* سوییچ نمایش جزئیات/توضیح محصول در اپ مشتری + اطمینان از وجود ستون description روی products.
* idempotent — value تنظیم موجود دست نخورده می‌ماند.
*/
return new class extends Migration
{
public function up(): void
{
if (Schema::hasTable('products') && ! Schema::hasColumn('products', 'description')) {
Schema::table('products', function ($table) {
$table->text('description')->nullable();
});
}
if (! Schema::hasTable('settings')) {
return;
}
if (! DB::table('settings')->where('key', 'show_product_details')->exists()) {
DB::table('settings')->insert([
'key' => 'show_product_details',
'value' => 'true',
'title_fa' => 'نمایش جزئیات اطلاعات محصول',
'type' => 'switch',
'can_edit' => 1,
'is_active' => 1,
'description' => 'روشن: بعد از انتخاب محصول در صفحه خرید/فروش، متن توضیح محصول نمایش داده می‌شود. خاموش: توضیح نشان داده نمی‌شود.',
'created_at' => now(),
'updated_at' => now(),
]);
}
}
public function down(): void
{
if (Schema::hasTable('settings')) {
DB::table('settings')->where('key', 'show_product_details')->delete();
}
// ستون description را حذف نمی‌کنیم — ممکن است داده داشته باشد
}
};
@@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* ستون amount با float() ساخته شده بود و لاراول ۸ آن را DOUBLE(8,2) می‌سازد؛
* سقفش ۹۹۹٬۹۹۹٫۹۹ است. هر سند ریالی بزرگ‌تر از یک میلیون در insert خطا می‌داد و
* چون فراخوانی‌ها داخل try/catch بودند، سند بی‌صدا گم می‌شد و پرگار واریز را نمی‌دید.
*/
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('pargar_sync_logs') || ! Schema::hasColumn('pargar_sync_logs', 'amount')) {
return;
}
DB::statement('ALTER TABLE `pargar_sync_logs` MODIFY `amount` DOUBLE NULL');
}
public function down(): void
{
// برگرداندن به DOUBLE(8,2) داده را خراب می‌کند؛ عمداً بدون عملیات.
}
};