Deploy Ladill QR Plus / deploy (push) Failing after 1s
Utility QR types only (URL, WiFi, link list, business, app download) with SSO, Billing API integration, public /q resolver, and qr-plus:import for platform migration. vCard and commerce types stay on the platform. Co-authored-by: Cursor <cursoragent@cursor.com>
62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Qr;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Billing\BillingClient;
|
|
use Illuminate\View\View;
|
|
|
|
class AccountController extends Controller
|
|
{
|
|
public function __construct(private BillingClient $billing) {}
|
|
|
|
private function topupUrl(): string
|
|
{
|
|
return 'https://'.config('app.account_domain').'/wallet';
|
|
}
|
|
|
|
/** @return array{0: int, 1: array<string, mixed>} */
|
|
private function billingSnapshot(?string $publicId): array
|
|
{
|
|
if (! $publicId) {
|
|
return [0, []];
|
|
}
|
|
|
|
$balanceMinor = $this->billing->balanceMinor($publicId);
|
|
$ledger = $this->billing->serviceLedger($publicId, 'qr');
|
|
|
|
return [$balanceMinor, $ledger];
|
|
}
|
|
|
|
public function wallet(): View
|
|
{
|
|
$user = auth()->user();
|
|
[$balanceMinor, $ledger] = $this->billingSnapshot($user?->public_id);
|
|
|
|
return view('qr.account.wallet', [
|
|
'balanceMinor' => $balanceMinor,
|
|
'spentMinor' => (int) ($ledger['spent_minor'] ?? 0),
|
|
'creditedMinor' => (int) ($ledger['credited_minor'] ?? 0),
|
|
'topupUrl' => $this->topupUrl(),
|
|
]);
|
|
}
|
|
|
|
public function billing(): View
|
|
{
|
|
$user = auth()->user();
|
|
[$balanceMinor, $ledger] = $this->billingSnapshot($user?->public_id);
|
|
|
|
return view('qr.account.billing', [
|
|
'balanceMinor' => $balanceMinor,
|
|
'spentMinor' => (int) ($ledger['spent_minor'] ?? 0),
|
|
'creditedMinor' => (int) ($ledger['credited_minor'] ?? 0),
|
|
'topupUrl' => $this->topupUrl(),
|
|
]);
|
|
}
|
|
|
|
public function settings(): View
|
|
{
|
|
return view('qr.account.settings', ['account' => auth()->user()]);
|
|
}
|
|
}
|