fix(sms): keep charge deposit defaults and unlock referral bonus

Empty SuperAdmin chargeInfo was wiping sms_charge_* on header refresh.
Seed those keys only when empty, and move referral_bonus_amount to can_edit=1.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-01 21:38:19 +03:30
co-authored by Cursor
parent cae41e72b8
commit 91a2dab440
8 changed files with 368 additions and 31 deletions
@@ -0,0 +1,58 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* مقدار پاداش معرف — can_edit=1 در تنظیمات عادی (معرف و پاداش).
* value ردیف موجود را تغییر نمی‌دهد.
*/
return new class extends Migration
{
public function up(): void
{
$key = 'referral_bonus_amount';
$meta = [
'title_fa' => 'مقدار پاداش معرف',
'description' => 'مبلغ یا مقدار پاداش معرف برای نمایش در پیامک‌ها و متن‌های دعوت.',
'type' => 'text',
];
$exists = DB::table('settings')->where('key', $key)->exists();
if (! $exists) {
$row = [
'key' => $key,
'value' => '',
'title_fa' => $meta['title_fa'],
'can_edit' => 1,
'is_active' => 1,
'description' => $meta['description'],
'type' => $meta['type'],
];
if (Schema::hasColumn('settings', 'menu')) {
$row['menu'] = 'referral';
}
DB::table('settings')->insert($row);
return;
}
$update = [
'title_fa' => $meta['title_fa'],
'description' => $meta['description'],
'type' => $meta['type'],
'can_edit' => 1,
'is_active' => 1,
];
if (Schema::hasColumn('settings', 'menu')) {
$update['menu'] = 'referral';
}
DB::table('settings')->where('key', $key)->update($update);
}
public function down(): void
{
// کلید را حذف نمی‌کنیم
}
};
@@ -0,0 +1,88 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
/**
* اطلاعات واریز شارژ سامانه پیامک — INSERT اگر نبود؛ value فقط اگر خالی باشد.
*/
return new class extends Migration
{
public function up(): void
{
$rows = [
'sms_charge_card_number' => [
'value' => '6219861961033817',
'title_fa' => 'شماره کارت شارژ پیامک',
'description' => 'شماره کارت برای واریز شارژ سامانه پیامکی (مودال اعتبار پیامک).',
'type' => 'text',
],
'sms_charge_sheba' => [
'value' => 'IR080560611828005603604201',
'title_fa' => 'شماره شبا شارژ پیامک',
'description' => 'شماره شبا برای واریز شارژ سامانه پیامکی.',
'type' => 'text',
],
'sms_charge_account_holder' => [
'value' => 'حسین منتظر',
'title_fa' => 'نام صاحب حساب شارژ پیامک',
'description' => 'نام صاحب حساب واریز شارژ سامانه پیامکی.',
'type' => 'text',
],
'sms_charge_note' => [
'value' => 'لطفا مبلغ مورد نظر خود جهت شارژ سامانه پیامکی را به شماره کارت یا حساب زیر واریز نمایید و تصویر فیش پرداختی را برای پشتیبانی بفرستید.',
'title_fa' => 'متن راهنمای شارژ پیامک',
'description' => 'متن راهنمای مودال شارژ اعتبار پیامک در پنل ادمین.',
'type' => 'longtext',
],
];
$hasMenu = Schema::hasColumn('settings', 'menu');
foreach ($rows as $key => $meta) {
$exists = DB::table('settings')->where('key', $key)->exists();
if (! $exists) {
$row = [
'key' => $key,
'value' => $meta['value'],
'title_fa' => $meta['title_fa'],
'can_edit' => 0,
'is_active' => 1,
'description' => $meta['description'],
'type' => $meta['type'],
];
if ($hasMenu) {
$row['menu'] = 'sms_charge';
}
DB::table('settings')->insert($row);
continue;
}
$update = [
'title_fa' => $meta['title_fa'],
'description' => $meta['description'],
'type' => $meta['type'],
'can_edit' => 0,
'is_active' => 1,
];
if ($hasMenu) {
$update['menu'] = 'sms_charge';
}
DB::table('settings')->where('key', $key)->update($update);
DB::table('settings')
->where('key', $key)
->where(function ($q) {
$q->whereNull('value')->orWhereRaw("TRIM(`value`) = ''");
})
->update(['value' => $meta['value']]);
}
}
public function down(): void
{
// کلید را حذف نمی‌کنیم
}
};