Surface branches and team as explicit settings sections.
Deploy Ladill POS / deploy (push) Successful in 37s

Embed branch list, switching, and team invites on the main settings page; dedicated routes redirect back with anchors.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-08 06:46:17 +00:00
co-authored by Cursor
parent afca49039b
commit 35970dfd2a
10 changed files with 176 additions and 43 deletions
@@ -23,10 +23,9 @@ class LocationController extends Controller
private SubscriptionService $subscriptions,
) {}
public function index(Request $request): View
public function index(Request $request): RedirectResponse
{
$owner = $this->ownerRef($request);
$account = ladill_account() ?? $request->user();
abort_unless(
app(\App\Services\Pos\PosMemberResolver::class)->canManageBranches(
@@ -37,13 +36,7 @@ class LocationController extends Controller
403,
);
$branches = PosLocation::owned($owner)->orderBy('name')->get();
return view('pos.branches.index', [
'branches' => $branches,
'canAddBranch' => $this->subscriptions->canAddLocation($account, $owner),
'hasMultiLocation' => $this->subscriptions->canUseMultiLocation($account),
]);
return redirect()->route('pos.settings')->withFragment('branches');
}
public function create(Request $request): View|RedirectResponse
@@ -85,7 +78,7 @@ class LocationController extends Controller
'is_default' => $isFirst,
]);
return redirect()->route('pos.branches.index')->with('success', 'Branch created.');
return redirect()->route('pos.settings')->withFragment('branches')->with('success', 'Branch created.');
}
public function edit(Request $request, PosLocation $location): View|RedirectResponse
@@ -130,7 +123,7 @@ class LocationController extends Controller
'service_style' => $data['service_style'],
]);
return redirect()->route('pos.branches.index')->with('success', 'Branch updated.');
return redirect()->route('pos.settings')->withFragment('branches')->with('success', 'Branch updated.');
}
public function destroy(Request $request, PosLocation $location): RedirectResponse
@@ -165,7 +158,7 @@ class LocationController extends Controller
$request->session()->forget('ladill_pos_location');
}
return redirect()->route('pos.branches.index')->with('success', 'Branch removed.');
return redirect()->route('pos.settings')->withFragment('branches')->with('success', 'Branch removed.');
}
public function switch(Request $request): RedirectResponse
+4 -12
View File
@@ -12,7 +12,6 @@ use App\Services\Pos\SubscriptionService;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;
use Illuminate\View\View;
class MemberController extends Controller
{
@@ -20,20 +19,13 @@ class MemberController extends Controller
public function __construct(private SubscriptionService $subscriptions) {}
public function index(Request $request): View|RedirectResponse
public function index(Request $request): RedirectResponse
{
if ($redirect = $this->guardManage($request)) {
return $redirect;
}
$owner = $this->ownerRef($request);
$members = PosMember::owned($owner)->with('location')->orderBy('created_at')->get();
return view('pos.team.index', [
'members' => $members,
'roles' => config('pos.roles', []),
'branches' => PosLocation::owned($owner)->orderBy('name')->get(),
]);
return redirect()->route('pos.settings')->withFragment('team');
}
public function store(Request $request, IdentityTeamClient $identity): RedirectResponse
@@ -89,7 +81,7 @@ class MemberController extends Controller
],
);
return back()->with('success', 'Invitation sent to '.$email.'.');
return back()->withFragment('team')->with('success', 'Invitation sent to '.$email.'.');
}
public function destroy(Request $request, PosMember $member): RedirectResponse
@@ -107,7 +99,7 @@ class MemberController extends Controller
$member->delete();
return back()->with('success', 'Team member removed.');
return back()->withFragment('team')->with('success', 'Team member removed.');
}
private function guardManage(Request $request): ?RedirectResponse
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Pos;
use App\Http\Controllers\Controller;
use App\Http\Controllers\Pos\Concerns\ScopesToAccount;
use App\Models\PosLocation;
use App\Models\PosMember;
use App\Models\PosTable;
use App\Services\Import\CrmProductImportService;
use App\Services\Import\MerchantCatalogImportService;
@@ -28,9 +29,21 @@ class SettingsController extends Controller
{
$owner = $this->ownerRef($request);
$location = $this->location($request);
$account = ladill_account() ?? $request->user();
$scope = $this->locationScope($request);
$branches = $scope === null
? PosLocation::owned($owner)->orderBy('name')->get()
: PosLocation::owned($owner)->whereKey($scope)->orderBy('name')->get();
return view('pos.settings', [
'location' => $location,
'branches' => $branches,
'members' => PosMember::owned($owner)->with('location')->orderBy('created_at')->get(),
'roles' => config('pos.roles', []),
'hasMultiLocation' => $this->subscriptions->canUseMultiLocation($account),
'hasTeamFeatures' => $this->subscriptions->canManageTeam($account),
'canAddBranch' => $this->subscriptions->canAddLocation($account, $owner),
'merchantImportEnabled' => (bool) config('pos.merchant_import_enabled', true),
'tables' => $this->scopeToLocation($request, PosTable::owned($owner))
->orderBy('area')->orderBy('position')->orderBy('label')->get(),
@@ -20,7 +20,7 @@
@endforeach
@if (! empty($canManageBranches))
<div class="mt-1 border-t border-slate-100 pt-1">
<a href="{{ route('pos.branches.index') }}" class="block rounded-lg px-3 py-2 text-sm text-indigo-600 hover:bg-slate-50">Manage branches</a>
<a href="{{ route('pos.settings') }}#branches" class="block rounded-lg px-3 py-2 text-sm text-indigo-600 hover:bg-slate-50">Manage branches</a>
</div>
@endif
</div>
@@ -23,7 +23,7 @@
</select>
</div>
<div class="flex justify-end gap-3">
<a href="{{ route('pos.branches.index') }}" class="rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Cancel</a>
<a href="{{ route('pos.settings') }}#branches" class="rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Cancel</a>
<button type="submit" class="btn-primary">Create branch</button>
</div>
</form>
+1 -1
View File
@@ -28,7 +28,7 @@
Default branch for admins
</label>
<div class="flex justify-end gap-3">
<a href="{{ route('pos.branches.index') }}" class="rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Cancel</a>
<a href="{{ route('pos.settings') }}#branches" class="rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50">Back</a>
<button type="submit" class="btn-primary">Save branch</button>
</div>
</form>
+10 -15
View File
@@ -1,19 +1,6 @@
<x-app-layout title="Settings">
<x-settings.page description="Branch settings, receipt footer, and catalog imports.">
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<p class="text-sm text-slate-600">
Editing <span class="font-semibold text-slate-900">{{ $location->name }}</span>
</p>
<div class="flex flex-wrap gap-3 text-sm">
@if (! empty($canManageBranches))
<a href="{{ route('pos.branches.index') }}" class="font-medium text-indigo-600 hover:text-indigo-800">Branches</a>
@endif
@if (! empty($canManageTeam))
<a href="{{ route('pos.team.index') }}" class="font-medium text-indigo-600 hover:text-indigo-800">Team</a>
@endif
</div>
</div>
<x-settings.card title="Branch settings" description="Register name, currency, service style, and receipt footer for this branch.">
<x-settings.page description="Configure this branch, manage locations, and invite team members.">
<x-settings.card title="This branch" description="Register name, currency, service style, and receipt options for {{ $location->name }}.">
<form method="POST" action="{{ route('pos.settings.update') }}" enctype="multipart/form-data" class="space-y-4">
@csrf
@method('PUT')
@@ -98,6 +85,14 @@
</form>
</x-settings.card>
<div class="mt-6 space-y-6">
@include('pos.settings._branches-section')
@if (! empty($canManageTeam))
@include('pos.settings._team-section')
@endif
</div>
@if ($location->isRestaurant())
<x-settings.card title="Import catalog" description="Seed your local POS catalog from CRM or Merchant storefronts. (Retail mode reads products live from CRM, so no import is needed.)">
<div class="flex flex-wrap gap-3">
@@ -0,0 +1,52 @@
<x-settings.card id="branches" title="Branches" description="Each branch is a separate register with its own receipts, sales, and settings. Switch the active branch here or from the top bar.">
@if ($branches->isNotEmpty())
<ul class="divide-y divide-slate-100">
@foreach ($branches as $branch)
<li class="flex items-center justify-between gap-4 py-3 first:pt-0 last:pb-0">
<div class="min-w-0">
<p class="font-medium text-slate-900">
{{ $branch->name }}
@if ($branch->id === $location->id)
<span class="ml-2 rounded-full bg-indigo-50 px-2 py-0.5 text-[10px] font-semibold uppercase text-indigo-700">Active</span>
@endif
@if ($branch->is_default)
<span class="ml-2 rounded-full bg-slate-100 px-2 py-0.5 text-[10px] font-semibold uppercase text-slate-500">Default</span>
@endif
</p>
<p class="mt-0.5 text-xs text-slate-500">
{{ strtoupper($branch->currency) }}
· {{ $branch->isRestaurant() ? 'Restaurant' : 'Retail' }}
</p>
</div>
<div class="flex shrink-0 items-center gap-3">
@if ($branch->id !== $location->id)
<form method="POST" action="{{ route('pos.location.switch') }}">
@csrf
<input type="hidden" name="location" value="{{ $branch->id }}">
<button type="submit" class="text-sm font-medium text-indigo-600 hover:text-indigo-800">Switch</button>
</form>
@endif
@if (! empty($canManageBranches) && $hasMultiLocation)
<a href="{{ route('pos.branches.edit', $branch) }}" class="text-sm font-medium text-slate-600 hover:text-slate-900">Edit</a>
@endif
</div>
</li>
@endforeach
</ul>
@else
<p class="text-sm text-slate-500">No branches yet.</p>
@endif
<div class="mt-4 flex flex-wrap items-center gap-3 border-t border-slate-100 pt-4">
@if (! empty($canManageBranches) && $hasMultiLocation && $canAddBranch)
<a href="{{ route('pos.branches.create') }}" class="btn-primary">Add branch</a>
@endif
@unless ($hasMultiLocation)
<p class="rounded-xl bg-amber-50 px-4 py-3 text-sm text-amber-900">
Multi-branch POS is available on
<a href="{{ route('pos.pro.index') }}" class="font-semibold underline">Pro or Business</a>.
Your account is limited to one branch.
</p>
@endunless
</div>
</x-settings.card>
@@ -0,0 +1,88 @@
<x-settings.card id="team" title="Team & branch access" description="Invite cashiers and managers to this POS account. Cashiers must be assigned to a branch — they can only use the register and view sales for that location.">
@if (! empty($canManageTeam) && $hasTeamFeatures)
<form method="POST" action="{{ route('pos.team.store') }}" class="grid gap-4 md:grid-cols-2">
@csrf
<div class="md:col-span-2">
<label for="team_email" class="text-sm font-medium text-slate-700">Email address</label>
<input type="email" id="team_email" name="email" value="{{ old('email') }}" required
placeholder="cashier@example.com"
class="mt-1.5 block w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
</div>
<div>
<label for="team_role" class="text-sm font-medium text-slate-700">Role</label>
<select id="team_role" name="role"
x-data
x-on:change="$dispatch('team-role-changed', $event.target.value)"
class="mt-1.5 block w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
@foreach ($roles as $key => $label)
<option value="{{ $key }}" @selected(old('role') === $key)>{{ $label }}</option>
@endforeach
</select>
</div>
<div x-data="{ role: @js(old('role', 'cashier')) }" @team-role-changed.window="role = $event.detail">
<label for="team_location_id" class="text-sm font-medium text-slate-700">Assigned branch</label>
<select id="team_location_id" name="location_id"
class="mt-1.5 block w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
<option value="">All branches</option>
@foreach ($branches as $branch)
<option value="{{ $branch->id }}" @selected((int) old('location_id') === $branch->id)>{{ $branch->name }}</option>
@endforeach
</select>
<p class="mt-1 text-xs text-slate-400" x-show="role === 'cashier'" x-cloak>
Required for cashiers they will only see this branch on the register and in sales.
</p>
</div>
<div class="md:col-span-2 flex justify-end">
<button type="submit" class="btn-primary">Send invite</button>
</div>
</form>
<div class="mt-6 border-t border-slate-100 pt-5">
<h3 class="text-sm font-semibold text-slate-900">Team members</h3>
@if ($members->isEmpty())
<p class="mt-2 text-sm text-slate-500">No team members yet. Invite a cashier or manager above.</p>
@else
<div class="mt-3 overflow-x-auto">
<table class="min-w-full text-sm">
<thead class="text-left text-xs uppercase text-slate-500">
<tr>
<th class="pb-2 pr-4">Member</th>
<th class="pb-2 pr-4">Role</th>
<th class="pb-2 pr-4">Branch</th>
<th class="pb-2"></th>
</tr>
</thead>
<tbody class="divide-y divide-slate-100">
@foreach ($members as $member)
@php
$display = str_contains($member->user_ref, '@')
? $member->user_ref
: (\App\Models\User::where('public_id', $member->user_ref)->value('email') ?? $member->user_ref);
@endphp
<tr>
<td class="py-3 pr-4">{{ $display }}</td>
<td class="py-3 pr-4">{{ $roles[$member->role] ?? $member->role }}</td>
<td class="py-3 pr-4">{{ $member->location?->name ?? 'All branches' }}</td>
<td class="py-3 text-right">
@if ($member->user_ref !== auth()->user()->public_id && $member->user_ref !== strtolower((string) auth()->user()->email))
<form method="POST" action="{{ route('pos.team.destroy', $member) }}" class="inline" onsubmit="return confirm('Remove this member?');">
@csrf
@method('DELETE')
<button type="submit" class="text-red-600 hover:text-red-800">Remove</button>
</form>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
@else
<p class="rounded-xl bg-amber-50 px-4 py-3 text-sm text-amber-900">
Team invites and branch assignment require
<a href="{{ route('pos.pro.index') }}" class="font-semibold underline">Ladill POS Pro or Business</a>.
</p>
@endif
</x-settings.card>
+1 -1
View File
@@ -99,7 +99,7 @@ class PosMultiBranchTest extends TestCase
'currency' => 'GHS',
'service_style' => 'retail',
])
->assertRedirect(route('pos.branches.index'));
->assertRedirect(route('pos.settings').'#branches');
$this->assertSame(2, PosLocation::owned($owner->public_id)->count());
}