Set Pro to GHS 100/mo and add sidebar Go Pro UI like Accounting.
Deploy Ladill Frontdesk / deploy (push) Successful in 33s

Adds a dedicated Pro page with wallet upgrade, gradient Upgrade to Pro
button in the sidebar footer, and view composer for plan status.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-06-28 02:12:49 +00:00
co-authored by Cursor
parent 33b6070207
commit cc3d4e9a63
11 changed files with 297 additions and 57 deletions
@@ -0,0 +1,89 @@
<?php
namespace App\Http\Controllers\Frontdesk;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Frontdesk\Concerns\ScopesToAccount;
use App\Services\Billing\BillingClient;
use App\Services\Frontdesk\FrontdeskPermissions;
use App\Services\Frontdesk\PlanService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\View\View;
class ProController extends Controller
{
use ScopesToAccount;
public function index(Request $request, PlanService $plans): View
{
$organization = $this->organization($request);
$canManage = app(FrontdeskPermissions::class)->isAdmin($this->member($request));
$settings = $organization->settings ?? [];
$expiresAt = ! empty($settings['plan_expires_at'])
? Carbon::parse($settings['plan_expires_at'])
: null;
return view('frontdesk.pro.index', [
'organization' => $organization,
'isPro' => $plans->isPro($organization),
'canManage' => $canManage,
'priceMinor' => $plans->proPriceMinor(),
'currency' => (string) config('billing.currency', 'GHS'),
'planExpiresAt' => $expiresAt,
'proFeatures' => [
'Unlimited branches & kiosk devices',
'Unlimited host email alerts',
'Webhooks & calendar (iCal) feeds',
'Scheduled report exports',
'Custom badge templates',
],
]);
}
public function subscribe(Request $request, PlanService $plans, BillingClient $billing): RedirectResponse
{
$this->authorizeAbility($request, 'settings.manage');
$organization = $this->organization($request);
if ($plans->isPro($organization)) {
return redirect()->route('frontdesk.pro.index')
->with('success', 'Your organization is already on Frontdesk Pro.');
}
$priceMinor = $plans->proPriceMinor();
$ownerRef = $organization->owner_ref;
try {
if (! $billing->canAfford($ownerRef, $priceMinor)) {
return redirect()->route('frontdesk.pro.index')
->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade to Pro.');
}
$charged = $billing->debit(
$ownerRef,
$priceMinor,
'frontdesk_pro',
'frontdesk-pro-'.$organization->id.'-'.now()->format('Y-m-d-His'),
'Ladill Frontdesk Pro — monthly subscription',
);
} catch (\Throwable) {
return redirect()->route('frontdesk.pro.index')
->with('error', 'Could not process upgrade. Please try again.');
}
if (! $charged) {
return redirect()->route('frontdesk.pro.index')
->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade to Pro.');
}
$settings = $organization->settings ?? [];
$settings['plan'] = 'pro';
$settings['plan_expires_at'] = now()->addMonth()->toIso8601String();
$organization->update(['settings' => $settings]);
return redirect()->route('frontdesk.pro.index')
->with('success', 'Welcome to Frontdesk Pro — active for one month.');
}
}
@@ -5,8 +5,7 @@ namespace App\Http\Controllers\Frontdesk;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Frontdesk\Concerns\ScopesToAccount;
use App\Services\Billing\BillingClient;
use App\Services\Frontdesk\PlanService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Cache;
@@ -39,44 +38,4 @@ class WalletController extends Controller
'formatted' => $currency.' '.number_format($minor / 100, 2),
]);
}
public function upgrade(Request $request, PlanService $plans, BillingClient $billing): RedirectResponse
{
$this->authorizeAbility($request, 'settings.manage');
$organization = $this->organization($request);
if ($plans->isPro($organization)) {
return back()->with('success', 'Your organization is already on Frontdesk Pro.');
}
$priceMinor = $plans->proPriceMinor();
$ownerRef = $organization->owner_ref;
try {
if (! $billing->canAfford($ownerRef, $priceMinor)) {
return back()->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade to Pro.');
}
$charged = $billing->debit(
$ownerRef,
$priceMinor,
'frontdesk_pro',
'frontdesk-pro-'.$organization->id.'-'.now()->format('Y-m'),
'Ladill Frontdesk Pro — monthly subscription',
);
} catch (\Throwable) {
return back()->with('error', 'Could not process upgrade. Please try again.');
}
if (! $charged) {
return back()->with('error', 'Insufficient wallet balance. Top up your Ladill wallet to upgrade to Pro.');
}
$settings = $organization->settings ?? [];
$settings['plan'] = 'pro';
$settings['plan_expires_at'] = now()->addMonth()->toIso8601String();
$organization->update(['settings' => $settings]);
return back()->with('success', 'Upgraded to Frontdesk Pro for one month.');
}
}
+19
View File
@@ -2,9 +2,13 @@
namespace App\Providers;
use App\Models\User;
use App\Services\Frontdesk\OrganizationResolver;
use App\Services\Frontdesk\PlanService;
use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
@@ -29,5 +33,20 @@ class AppServiceProvider extends ServiceProvider
RateLimiter::for('device-heartbeat', function (Request $request) {
return Limit::perMinute(60)->by((string) ($request->header('X-Device-Token') ?? $request->ip()));
});
View::composer('partials.sidebar', function ($view) {
/** @var User|null $user */
$user = auth()->user();
$isPro = false;
if ($user) {
$organization = app(OrganizationResolver::class)->resolveForUser($user);
if ($organization) {
$isPro = app(PlanService::class)->isPro($organization);
}
}
$view->with('isPro', $isPro);
});
}
}
+1 -1
View File
@@ -78,6 +78,6 @@ class PlanService
public function proPriceMinor(): int
{
return (int) config('frontdesk.plans.pro.price_minor', 9900);
return (int) config('frontdesk.plans.pro.price_minor', 10000);
}
}
+1 -1
View File
@@ -132,7 +132,7 @@ return [
],
'pro' => [
'label' => 'Pro',
'price_minor' => (int) env('FRONTDESK_PRO_PRICE_MINOR', 9900),
'price_minor' => (int) env('FRONTDESK_PRO_PRICE_MINOR', 10000),
'max_branches' => null,
'max_kiosk_devices' => null,
'free_emails_per_month' => env('FRONTDESK_PRO_FREE_EMAILS_PER_MONTH') !== null
@@ -6,12 +6,9 @@
<div class="mt-6 rounded-2xl border border-indigo-200 bg-indigo-50 p-6">
<h2 class="font-semibold text-indigo-900">Upgrade to Pro</h2>
<p class="mt-2 text-sm text-indigo-800">
GHS {{ number_format($proPriceMinor / 100, 2) }} / month from your Ladill wallet unlimited branches and kiosks, integrations, scheduled reports, and more.
GHS {{ number_format($proPriceMinor / 100, 0) }} / month from your Ladill wallet unlimited branches and kiosks, integrations, scheduled reports, and more.
</p>
<form method="POST" action="{{ route('frontdesk.settings.upgrade') }}" class="mt-4">
@csrf
<button type="submit" class="btn-primary">Upgrade from wallet</button>
</form>
<a href="{{ route('frontdesk.pro.index') }}" class="btn-primary mt-4 inline-flex">View Pro plans</a>
<p class="mt-3 text-xs text-indigo-700">
<a href="{{ route('frontdesk.wallet') }}" class="underline">Top up your wallet</a> if you need more balance.
</p>
@@ -0,0 +1,59 @@
<x-app-layout title="Pro" heading="Frontdesk Pro">
@php
$price = number_format($priceMinor / 100, 2);
@endphp
<div class="mx-auto max-w-2xl">
@if (session('upsell'))
<div class="mb-4 rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800">{{ session('upsell') }}</div>
@endif
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<div class="bg-gradient-to-r from-indigo-700 via-teal-600 to-cyan-500 px-6 py-7 text-white">
<div class="flex items-center gap-2">
<span class="rounded-md bg-white/20 px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide">Pro</span>
@if ($isPro)
<span class="rounded-md bg-emerald-400/90 px-2 py-0.5 text-[11px] font-semibold text-emerald-950">Active</span>
@endif
</div>
<h1 class="mt-3 text-2xl font-bold">Ladill Frontdesk Pro</h1>
<p class="mt-1 text-sm text-white/80">Everything in Free, plus unlimited scale, integrations, and unlimited host email alerts.</p>
<p class="mt-4 text-3xl font-bold">{{ $currency }} {{ $price }}<span class="text-base font-medium text-white/70"> / month</span></p>
</div>
<div class="px-6 py-6">
<ul class="grid gap-3 sm:grid-cols-2">
@foreach ($proFeatures as $feature)
<li class="flex items-start gap-2 text-sm text-slate-700">
<svg class="mt-0.5 h-4 w-4 shrink-0 text-emerald-500" fill="none" viewBox="0 0 24 24" stroke-width="2.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5"/></svg>
<span>{{ $feature }}</span>
</li>
@endforeach
</ul>
<div class="mt-6 border-t border-slate-100 pt-6">
@if ($isPro)
<div class="text-sm text-slate-600">
@if ($planExpiresAt)
Pro is active until <strong>{{ $planExpiresAt->format('d M Y') }}</strong>.
@else
Your organization is on Frontdesk Pro.
@endif
</div>
<p class="mt-3 text-xs text-slate-400">SMS host alerts still bill at Ladill platform rates from your wallet.</p>
@elseif ($canManage)
<form method="post" action="{{ route('frontdesk.pro.subscribe') }}">
@csrf
<button class="btn-primary w-full sm:w-auto">
Upgrade to Pro {{ $currency }} {{ $price }}/mo from wallet
</button>
</form>
<p class="mt-3 text-xs text-slate-400">Billed monthly from your Ladill wallet. Host SMS remains pay-as-you-go on every plan.</p>
@else
<p class="rounded-xl bg-slate-50 px-4 py-3 text-sm text-slate-500">Ask an organization administrator to upgrade this workspace to Pro.</p>
@endif
</div>
</div>
</div>
</div>
</x-app-layout>
@@ -20,10 +20,7 @@
</p>
</div>
@if (! $isPro)
<form method="POST" action="{{ route('frontdesk.settings.upgrade') }}">
@csrf
<button type="submit" class="btn-primary text-sm">Upgrade to Pro (GHS {{ number_format($proPriceMinor / 100, 2) }}/mo)</button>
</form>
<a href="{{ route('frontdesk.pro.index') }}" class="btn-primary text-sm">Upgrade to Pro (GHS {{ number_format($proPriceMinor / 100, 0) }}/mo)</a>
@endif
</div>
<dl class="mt-4 grid gap-3 text-sm sm:grid-cols-2">
+15 -2
View File
@@ -104,11 +104,24 @@
<div class="shrink-0 border-t border-slate-100 px-3 py-3">
<a href="{{ route('frontdesk.settings') }}"
class="group flex items-center gap-3 rounded-lg px-3 py-2 text-[13px] transition {{ request()->routeIs('frontdesk.settings*') ? 'bg-indigo-50 text-indigo-700 font-semibold' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900' }}">
<svg class="h-[18px] w-[18px] shrink-0 {{ request()->routeIs('frontdesk.settings*') ? 'text-indigo-600' : 'text-slate-400' }}" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
class="group flex items-center gap-3 rounded-lg px-3 py-2 text-[13px] transition {{ request()->routeIs('frontdesk.settings') && ! request()->routeIs('frontdesk.pro.*') ? 'bg-indigo-50 text-indigo-700 font-semibold' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900' }}">
<svg class="h-[18px] w-[18px] shrink-0 {{ request()->routeIs('frontdesk.settings') && ! request()->routeIs('frontdesk.pro.*') ? 'text-indigo-600' : 'text-slate-400' }}" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" d="M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.325.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 0 1 1.37.49l1.296 2.247a1.125 1.125 0 0 1-.26 1.431l-1.003.827c-.293.241-.438.613-.43.992a7.723 7.723 0 0 1 0 .255c-.008.378.137.75.43.991l1.004.827c.424.35.534.955.26 1.43l-1.298 2.247a1.125 1.125 0 0 1-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.47 6.47 0 0 1-.22.128c-.331.183-.581.495-.644.869l-.213 1.281c-.09.543-.56.94-1.11.94h-2.594c-.55 0-1.019-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 0 1-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 0 1-1.369-.49l-1.297-2.247a1.125 1.125 0 0 1 .26-1.431l1.004-.827c.292-.241.437-.613.43-.992a6.932 6.932 0 0 1 0-.255c.007-.378-.138-.75-.43-.991l-1.004-.827a1.125 1.125 0 0 1-.26-1.43l1.297-2.247a1.125 1.125 0 0 1 1.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.086.22-.128.332-.183.582-.495.644-.869l.214-1.281Z" /><path stroke-linecap="round" stroke-linejoin="round" d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z" />
</svg>
<span class="flex-1 truncate">Settings</span>
</a>
@php $proActive = request()->routeIs('frontdesk.pro.*'); @endphp
@if (! empty($isPro))
<a href="{{ route('frontdesk.pro.index') }}" class="group mt-0.5 flex items-center gap-3 rounded-lg px-3 py-2 text-[13px] transition {{ $proActive ? 'bg-indigo-50 text-indigo-700 font-semibold' : 'text-slate-600 hover:bg-slate-50 hover:text-slate-900' }}">
<svg class="h-[18px] w-[18px] shrink-0 text-amber-500" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.25c.3 0 .58.18.7.46l2.36 5.5 5.96.5a.75.75 0 0 1 .43 1.31l-4.53 3.9 1.36 5.83a.75.75 0 0 1-1.12.81L12 17.77l-5.16 3a.75.75 0 0 1-1.12-.81l1.36-5.83-4.53-3.9a.75.75 0 0 1 .43-1.31l5.96-.5 2.36-5.5c.12-.28.4-.46.7-.46Z"/></svg>
<span>Frontdesk Pro</span>
</a>
@else
<a href="{{ route('frontdesk.pro.index') }}" class="group mt-0.5 flex items-center gap-3 rounded-lg bg-gradient-to-r from-indigo-600 to-emerald-500 px-3 py-2 text-[13px] font-semibold text-white shadow-sm transition hover:opacity-95">
<svg class="h-[18px] w-[18px] shrink-0" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2.25c.3 0 .58.18.7.46l2.36 5.5 5.96.5a.75.75 0 0 1 .43 1.31l-4.53 3.9 1.36 5.83a.75.75 0 0 1-1.12.81L12 17.77l-5.16 3a.75.75 0 0 1-1.12-.81l1.36-5.83-4.53-3.9a.75.75 0 0 1 .43-1.31l5.96-.5 2.36-5.5c.12-.28.4-.46.7-.46Z"/></svg>
<span>Upgrade to Pro</span>
</a>
@endif
</div>
</div>
+5 -2
View File
@@ -16,7 +16,7 @@ use App\Http\Controllers\Frontdesk\KioskController;
use App\Http\Controllers\Frontdesk\KioskDeviceController;
use App\Http\Controllers\Frontdesk\MemberController;
use App\Http\Controllers\Frontdesk\OnboardingController;
use App\Http\Controllers\Frontdesk\QrScanController;
use App\Http\Controllers\Frontdesk\ProController;
use App\Http\Controllers\Frontdesk\ReceptionDeskController;
use App\Http\Controllers\Frontdesk\ReportController;
use App\Http\Controllers\Frontdesk\SecurityController;
@@ -143,9 +143,12 @@ Route::middleware(['auth', 'platform.session'])->group(function () {
Route::post('/compliance/visitors/{visitorId}/restore', [ComplianceController::class, 'restoreVisitor'])->name('frontdesk.compliance.visitors.restore');
Route::post('/compliance/visits/{visitId}/restore', [ComplianceController::class, 'restoreVisit'])->name('frontdesk.compliance.visits.restore');
Route::get('/pro', [ProController::class, 'index'])->name('frontdesk.pro.index');
Route::post('/pro/subscribe', [ProController::class, 'subscribe'])->name('frontdesk.pro.subscribe');
Route::get('/settings', [SettingsController::class, 'edit'])->name('frontdesk.settings');
Route::put('/settings', [SettingsController::class, 'update'])->name('frontdesk.settings.update');
Route::post('/settings/upgrade', [WalletController::class, 'upgrade'])->name('frontdesk.settings.upgrade');
Route::post('/settings/upgrade', [ProController::class, 'subscribe'])->name('frontdesk.settings.upgrade');
Route::get('/branches', [BranchController::class, 'index'])->name('frontdesk.branches.index');
Route::get('/branches/create', [BranchController::class, 'create'])->name('frontdesk.branches.create');
+104
View File
@@ -0,0 +1,104 @@
<?php
namespace Tests\Feature;
use App\Http\Middleware\EnsurePlatformSession;
use App\Models\Branch;
use App\Models\Member;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Http;
use Tests\TestCase;
class FrontdeskProTest extends TestCase
{
use RefreshDatabase;
protected User $owner;
protected Organization $organization;
protected function setUp(): void
{
parent::setUp();
$this->withoutMiddleware(EnsurePlatformSession::class);
config(['billing.api_url' => 'https://billing.test']);
$this->owner = User::create([
'public_id' => 'pro-owner-001',
'name' => 'Owner',
'email' => 'owner@example.com',
]);
$this->organization = Organization::create([
'owner_ref' => $this->owner->public_id,
'name' => 'Pro Org',
'slug' => 'pro-org',
'settings' => ['onboarded' => true, 'badge_expiry_hours' => 8],
]);
Member::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'user_ref' => $this->owner->public_id,
'role' => 'org_admin',
]);
Branch::create([
'owner_ref' => $this->owner->public_id,
'organization_id' => $this->organization->id,
'name' => 'HQ',
'is_active' => true,
]);
}
public function test_pro_page_renders_for_free_organization(): void
{
$this->actingAs($this->owner)
->get(route('frontdesk.pro.index'))
->assertOk()
->assertSee('Ladill Frontdesk Pro')
->assertSee('GHS 100')
->assertSee('Upgrade to Pro');
}
public function test_sidebar_shows_upgrade_to_pro_on_dashboard(): void
{
$this->actingAs($this->owner)
->get(route('frontdesk.dashboard'))
->assertOk()
->assertSee('Upgrade to Pro');
}
public function test_subscribe_upgrades_organization(): void
{
Http::fake([
'billing.test/can-afford*' => Http::response(['affordable' => true]),
'billing.test/debit' => Http::response(['ok' => true]),
]);
$this->actingAs($this->owner)
->post(route('frontdesk.pro.subscribe'))
->assertRedirect(route('frontdesk.pro.index'))
->assertSessionHas('success');
$this->assertSame('pro', $this->organization->fresh()->settings['plan']);
}
public function test_pro_sidebar_shows_active_label_after_upgrade(): void
{
$this->organization->update([
'settings' => array_merge($this->organization->settings ?? [], [
'plan' => 'pro',
'plan_expires_at' => now()->addMonth()->toIso8601String(),
]),
]);
$this->actingAs($this->owner)
->get(route('frontdesk.dashboard'))
->assertOk()
->assertSee('Frontdesk Pro')
->assertDontSee('Upgrade to Pro');
}
}