@php
$mgr = new \App\Classes\AiCreditManager($user->id);
$pkg = $mgr->getPackage();
$lim = $mgr->getUserEmailLimits();
$balance = (int) ($lim->ai_credits ?? 0);
$alloc = (int) ($pkg->ai_default_credits ?? 0);
$used = (int) ($lim->ai_credits_used_this_month ?? 0);
@endphp
@lang('plan.ai_credits.balance')
{{ number_format($balance) }}
@lang('plan.ai_credits.monthly_allocation'): {{ number_format($alloc) }}
·
@lang('plan.ai_credits.used_this_month'): {{ number_format($used) }}
·
{{ $mgr->isAiOveruseAllowed() ? trans('plan.ai_credits.overuse_allowed') : trans('plan.ai_credits.overuse_not_allowed') }}
@include('plan._meter', [
'label' => trans('plan.ai_credits.used_this_month'),
'used' => $used,
{{-- null reads as Unlimited in the meter, so a plan that grants no AI
credits announced unlimited AI. --}}
'limit' => $alloc,
'icon' => 'la la-magic',
'help' => $resetMonthly,
])
@php
// `mumara.ai.tiers` has never existed, so this table has never appeared.
// The tiers an admin has switched off are not on offer, and the credits
// a client spends are the base cost plus the markup they are billed at.
$markup = (int) (getApplicationSettings('mumara_ai_user_markup') ?: 50);
$tiers = [];
foreach (config('mumara.ai_tiers', []) as $tierKey => $tierCfg) {
$enabled = getApplicationSettings('mumara_ai_tier_'.$tierKey);
if (! ($enabled === false || $enabled === '' || $enabled === null || $enabled == 'on')) {
continue;
}
if (isset($tierCfg['cost']) && is_array($tierCfg['cost'])) {
$tierCfg['cost'] = array_map(fn ($c) => (int) ceil($c * (1 + $markup / 100)), $tierCfg['cost']);
}
$tiers[$tierKey] = $tierCfg;
}
@endphp
@if(!empty($tiers))
@lang('plan.ai_credits.tier_costs')
| @lang('plan.ai_credits.tier_fast') / @lang('plan.ai_credits.tier_balanced') / @lang('plan.ai_credits.tier_advanced') |
@lang('plan.ai_credits.credits') |
@foreach(($tiers ?? []) as $tierKey => $tierCfg)
| {{ $tierCfg['label'] ?? $tierKey }} |
@if(isset($tierCfg['cost']))
{{ is_array($tierCfg['cost']) ? (min($tierCfg['cost']) . '–' . max($tierCfg['cost'])) : $tierCfg['cost'] }}
@else
—
@endif
|
@endforeach
@endif
{{-- "Contact your administrator" is right for a self-hosted install and
wrong for a hosted one, where the administrator is us. An addon can
filter this line: hook_filter('PlanHelpLine', ['content' => $line]). --}}
{{ hook_filter('PlanHelpLine', ['content' => trans('plan.common.contact_admin')]) }}