@extends('layouts.user')
@section('title')
Purchase AI Plan
@endsection
@section('content')
@php
$user = auth()->user();
$mainBalance = $user->balance;
$grantBalance = $user->grant_balance ?? 0;
$canAffordMain = $mainBalance >= $plan->price;
$canAffordGrant= $grantBalance >= $plan->price;
$activeGrant = \App\Models\Grant::where('user_id', $user->id)
->where('status', 1)
->where('expires_at', '>', now())
->orderByDesc('expires_at')
->first();
$hasGrant = $activeGrant !== null;
// After buying the plan the user must fund it from the SAME wallet.
// Pre-calculate whether each wallet can ALSO cover the minimum fund amount.
$minFund = $plan->min_fund ?? 0;
// What remains in each wallet after the purchase cost is deducted?
$mainAfterPurchase = $mainBalance - $plan->price;
$grantAfterPurchase = $grantBalance - $plan->price;
// Can they meet the minimum funding requirement from what's left?
$mainCanFund = $mainAfterPurchase >= $minFund;
$grantCanFund = $grantAfterPurchase >= $minFund;
@endphp
{{ $user->username }}
{{ $user->email }}
{{ ucfirst($plan->name) }}
${{ number_format($plan->price, 2) }}
One-time plan purchase · 30-day access
{{-- Plan details --}}
Plan{{ ucfirst($plan->name) }}
Capital Range${{ number_format($plan->min_fund, 2) }} – ${{ number_format($plan->max_fund, 2) }}
AccessOne-time funding until next purchase
{{ $plan->description }}
{{-- Wallet selector --}}
Choose payment source
Whichever wallet you purchase with, you must also fund the bot from that same wallet.
Minimum bot capital: ${{ number_format($minFund, 2) }}.