add header show SMSpanel

This commit is contained in:
2026-07-07 17:42:09 +03:30
parent 10460beb5b
commit 628ee48bea
5 changed files with 163 additions and 5 deletions
@@ -37,6 +37,7 @@ class SmsPanelController extends Controller
'alert_days_sent' => (int) $wallet->alert_days_sent,
'last_alert_date' => $wallet->last_alert_date?->toDateString(),
],
'deposit' => SmsWalletService::getDepositInfo(),
'stats' => [
'today' => [
'parts' => (int) ($todayStats->total_parts ?? 0),
@@ -52,6 +53,57 @@ class SmsPanelController extends Controller
]);
}
/**
* خلاصه سبک کیف پول برای نمایش «اعتبار پیامک» در هدر؛ برای همه ادمین‌ها.
*/
public function walletSummary()
{
if (! SmsWalletService::isBillingEnabled()) {
return response()->json([
'enabled' => false,
'balance' => 0,
'is_blocked' => false,
'deposit' => SmsWalletService::getDepositInfo(),
]);
}
$balance = 0;
$isBlocked = false;
if (SmsWalletService::isBillingOperational()) {
$wallet = app(SmsWalletService::class)->getWallet();
$balance = (int) $wallet->balance;
$isBlocked = (bool) $wallet->is_blocked;
}
return response()->json([
'enabled' => true,
'balance' => $balance,
'is_blocked' => $isBlocked,
'deposit' => SmsWalletService::getDepositInfo(),
]);
}
/**
* ویرایش اطلاعات واریز (کارت/شبا/نام/متن) — فقط سوپرادمین پنل پیامک.
*/
public function updateDepositInfo(Request $request)
{
$data = $request->validate([
'card_number' => 'nullable|string|max:50',
'sheba' => 'nullable|string|max:50',
'account_holder' => 'nullable|string|max:191',
'note' => 'nullable|string|max:2000',
]);
$deposit = SmsWalletService::setDepositInfo($data);
return response()->json([
'message' => 'اطلاعات واریز به‌روزرسانی شد.',
'deposit' => $deposit,
]);
}
public function charge(Request $request)
{
$data = $request->validate([