fix some bugs from tahesab
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* سوییچهای جدا برای نمایش خرید/فروش باز و متای کارت محصول.
|
||||
* idempotent — value موجود دست نخورده میماند.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('settings')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rows = [
|
||||
[
|
||||
'key' => 'show_product_trade_status',
|
||||
'value' => 'false',
|
||||
'title_fa' => 'نمایش خرید/فروش باز روی کارت محصول',
|
||||
'description' => 'روشن: روی کارت محصول برچسب خرید باز/بسته و فروش باز/بسته نمایش داده میشود. خاموش: مخفی است.',
|
||||
],
|
||||
[
|
||||
'key' => 'show_product_card_meta',
|
||||
'value' => 'true',
|
||||
'title_fa' => 'نمایش دسته و تحویل و مقدار روی کارت محصول',
|
||||
'description' => 'روشن: روی کارت محصول دستهبندی، وضعیت تحویل فیزیکی و مقدار/وزن نمایش داده میشود. خاموش: مخفی است.',
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($rows as $row) {
|
||||
if (DB::table('settings')->where('key', $row['key'])->exists()) {
|
||||
DB::table('settings')->where('key', $row['key'])->update([
|
||||
'title_fa' => $row['title_fa'],
|
||||
'description' => $row['description'],
|
||||
'type' => 'switch',
|
||||
'can_edit' => 1,
|
||||
'is_active' => 1,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
continue;
|
||||
}
|
||||
|
||||
DB::table('settings')->insert([
|
||||
'key' => $row['key'],
|
||||
'value' => $row['value'],
|
||||
'title_fa' => $row['title_fa'],
|
||||
'type' => 'switch',
|
||||
'can_edit' => 1,
|
||||
'is_active' => 1,
|
||||
'description' => $row['description'],
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if (! Schema::hasTable('settings')) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::table('settings')->whereIn('key', [
|
||||
'show_product_trade_status',
|
||||
'show_product_card_meta',
|
||||
])->delete();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user