diff --git a/app/Http/Controllers/Transfer/FilesController.php b/app/Http/Controllers/Transfer/FilesController.php index 2aef591..526f72b 100644 --- a/app/Http/Controllers/Transfer/FilesController.php +++ b/app/Http/Controllers/Transfer/FilesController.php @@ -6,6 +6,7 @@ use App\Http\Controllers\Controller; use App\Models\Transfer; use App\Models\TransferFile; use App\Models\User; +use App\Services\Billing\BillingClient; use App\Services\Transfer\FileStorageService; use App\Services\Transfer\TransferRecipientMailService; use App\Services\Transfer\TransferService; @@ -24,6 +25,7 @@ class FilesController extends Controller public function __construct( private TransferService $transfers, private FileStorageService $storage, + private BillingClient $billing, ) {} public function index(Request $request): View @@ -88,6 +90,19 @@ class FilesController extends Controller ->where('status', '!=', Transfer::STATUS_DELETED) ->sum('storage_bytes'); + $fileCount = TransferFile::query() + ->whereHas('transfer', fn ($q) => $q + ->where('user_id', $account->id) + ->where('status', '!=', Transfer::STATUS_DELETED)) + ->count(); + + $balanceMinor = 0; + try { + $balanceMinor = $this->billing->balanceMinor($account->public_id); + } catch (\Throwable) { + // Balance is informational on this page. + } + return view('transfer.files.index', [ 'files' => $files, 'folders' => $folders, @@ -99,6 +114,8 @@ class FilesController extends Controller 'storageBytes' => (int) $storageBytes, 'storageGb' => round($storageBytes / (1024 * 1024 * 1024), 2), 'pricePerGb' => (float) config('transfer.price_per_gb_month', 0.30), + 'fileCount' => $fileCount, + 'balanceMinor' => $balanceMinor, ]); } diff --git a/app/Http/Controllers/Transfer/TransferController.php b/app/Http/Controllers/Transfer/TransferController.php index 2d13a19..886bac9 100644 --- a/app/Http/Controllers/Transfer/TransferController.php +++ b/app/Http/Controllers/Transfer/TransferController.php @@ -25,6 +25,7 @@ class TransferController extends Controller private ChunkedUploadService $chunkedUploads, private QrImageGeneratorService $imageGenerator, private QrPdfExporter $pdfExporter, + private BillingClient $billing, ) {} public function index(Request $request): View @@ -58,7 +59,34 @@ class TransferController extends Controller ->paginate(20) ->withQueryString(); - return view('transfer.transfers.index', compact('transfers', 'search', 'status', 'sort')); + $transferCount = Transfer::query() + ->where('user_id', $account->id) + ->shareTransfers() + ->where('status', '!=', Transfer::STATUS_DELETED) + ->count(); + + $activeCount = Transfer::query() + ->where('user_id', $account->id) + ->shareTransfers() + ->accessible() + ->count(); + + $balanceMinor = 0; + try { + $balanceMinor = $this->billing->balanceMinor($account->public_id); + } catch (\Throwable) { + // Balance is informational on this page. + } + + return view('transfer.transfers.index', compact( + 'transfers', + 'search', + 'status', + 'sort', + 'transferCount', + 'activeCount', + 'balanceMinor', + )); } public function create(BillingClient $billing): View diff --git a/resources/views/transfer/files/index.blade.php b/resources/views/transfer/files/index.blade.php index 42794ae..0ee3c99 100644 --- a/resources/views/transfer/files/index.blade.php +++ b/resources/views/transfer/files/index.blade.php @@ -29,7 +29,7 @@ ])->values(); @endphp -
{{ $fmtBytes($storageBytes) }} stored (~GHS {{ number_format($storageGb * $pricePerGb, 2) }}/month)
-+ Upload, organise, and share files from your Ladill Transfer storage. Billed at GHS {{ number_format($pricePerGb, 2) }}/GB per month. +
+All your file shares — active, grace, and expired.
+ ++ All your file shares — active, grace, and expired. Each transfer gets a QR code and download link for recipients. +
+