fix(settings): fee only from fee_service_charge_percentage; deploy:tenant

Remove service_charge_percentage alias and config/fee.php fallback (empty → 0).
Move code-managed Montzar/price runtime keys to can_edit=1 in deploy SQL.
Add settings:deploy and deploy:tenant artisan commands for server deploy.
Advanced admin settings merge runtime keys from local DB; block manual edits.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-19 19:55:29 +03:30
co-authored by Cursor
parent 5b2ed2e5fc
commit 027170a33f
12 changed files with 353 additions and 142 deletions
@@ -29,25 +29,11 @@ class SettingsController extends Controller
->orderBy('key');
if ($request->boolean('system_only')) {
if (! $request->boolean('skip_overlay')) {
$overlay = app(SuperAdminProgramSettingsOverlay::class)->items();
if ($overlay) {
return response()->json($this->authorizeSettingsPayload($this->overlayToRows($overlay)));
}
}
$local = $query->get();
$rows = $query
->where(function ($q) {
$q->where('can_edit', 0)->orWhere('can_edit', false)->orWhere('can_edit', '0');
})
->where(function ($q) {
$q->where('is_active', 1)
->orWhere('is_active', true)
->orWhere('is_active', '1');
})
->get();
return response()->json($this->authorizeSettingsPayload($rows));
return response()->json($this->authorizeSettingsPayload(
$this->composeSystemSettings($local)
));
}
if ($request->boolean('editable_only')) {
@@ -92,6 +78,13 @@ class SettingsController extends Controller
$setting = new Setting();
$setting->key = $request->key;
$setting->can_edit = 1;
} elseif (
SuperAdminProgramSettingsOverlay::isRuntime((string) $request->key)
&& ! $this->isPanelManagedKey((string) $request->key)
) {
return response()->json([
'message' => 'این مقدار توسط سیستم به‌روز می‌شود و از پنل قابل ویرایش نیست',
], 403);
} elseif (!$setting->can_edit && !$this->isPanelManagedKey((string) $request->key)) {
return response()->json([
'message' => 'این تنظیم از سوپرادمین کنترل می‌شود و در پنل خانگی قابل ویرایش نیست',
@@ -163,6 +156,44 @@ class SettingsController extends Controller
return in_array($key, self::PANEL_MANAGED_KEYS, true);
}
/**
* تنظیمات پیشرفته: can_edit=0 (سوپرادمین) + کلیدهای can_edit=1 که کد مستقیم می‌نویسد.
*/
private function composeSystemSettings($localRows)
{
$overlay = app(SuperAdminProgramSettingsOverlay::class);
$saMap = $overlay->map();
$byKey = [];
if ($saMap !== null) {
foreach ($saMap as $key => $item) {
if (! is_array($item)) {
continue;
}
$byKey[(string) $key] = $this->overlayRowToSetting($item);
}
} else {
foreach ($localRows as $row) {
if (! $this->isEditableCanEdit($row->can_edit ?? null)) {
$byKey[(string) $row->key] = $row;
}
}
}
foreach ($localRows as $row) {
$key = (string) $row->key;
if (
SuperAdminProgramSettingsOverlay::isLocalOwned($key)
|| SuperAdminProgramSettingsOverlay::isRuntime($key)
) {
$byKey[$key] = $row;
}
}
return collect(array_values($byKey))->sortBy(fn ($row) => (string) ($row->key ?? ''))->values();
}
/**
* get_settings: کلیدهای سوپرادمین (can_edit=0) + ردیف‌های جدول لوکال با can_edit=1.
* اگر سوپرادمین در دسترس نباشد کل جدول لوکال برمی‌گردد.