Add retail/restaurant mode toggle to the register
Deploy Ladill POS / deploy (push) Successful in 45s

A segmented Retail | Restaurant control in the register header flips the
location's service_style in place (RegisterController@setMode → pos.mode.set).
Switching to restaurant lands on the Floor and reveals Floor/Kitchen/Menu in the
sidebar; switching to retail stays on the register. Covered by PosRestaurantTest.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
isaacclad
2026-06-25 12:03:46 +00:00
co-authored by Claude Opus 4.8
parent 1bbc9490f1
commit 0d816daed3
4 changed files with 47 additions and 0 deletions
@@ -4,6 +4,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\PosProduct;
use App\Models\PosSale;
use App\Services\Pos\PosLocationService;
@@ -37,6 +38,21 @@ class RegisterController extends Controller
]);
}
/** Quick switch between retail and restaurant service from the register. */
public function setMode(Request $request): RedirectResponse
{
$data = $request->validate(['style' => ['required', 'in:retail,restaurant']]);
$location = $this->locations->ensureDefault($this->ownerRef($request));
$location->update(['service_style' => $data['style']]);
if ($data['style'] === PosLocation::STYLE_RESTAURANT) {
return redirect()->route('pos.floor')->with('success', 'Restaurant mode on — Floor, Kitchen & Menu are now in the sidebar.');
}
return redirect()->route('pos.register')->with('success', 'Retail mode on.');
}
/** @return list<array<string, mixed>> */
private function crmCustomers(string $owner): array
{
+15
View File
@@ -10,6 +10,21 @@
<div>
<h1 class="text-lg font-semibold text-slate-900">Register</h1>
<p class="mt-1 text-sm text-slate-500">{{ $location->name }} · {{ $location->currency }}</p>
<form method="post" action="{{ route('pos.mode.set') }}" class="mt-2 inline-flex rounded-xl bg-slate-100 p-0.5">
@csrf
<button name="style" value="retail"
@class([
'rounded-lg px-3 py-1.5 text-xs font-semibold transition',
'bg-white text-slate-900 shadow-sm' => ! $location->isRestaurant(),
'text-slate-500 hover:text-slate-700' => $location->isRestaurant(),
])>Retail</button>
<button name="style" value="restaurant"
@class([
'rounded-lg px-3 py-1.5 text-xs font-semibold transition',
'bg-white text-slate-900 shadow-sm' => $location->isRestaurant(),
'text-slate-500 hover:text-slate-700' => ! $location->isRestaurant(),
])>Restaurant</button>
</form>
</div>
<div class="flex gap-2">
<button type="button" @click="tab = 'catalog'" :class="tab === 'catalog' ? 'bg-indigo-600 text-white' : 'bg-white text-slate-700 ring-1 ring-slate-200'"
+1
View File
@@ -51,6 +51,7 @@ Route::middleware(['auth', 'platform.session'])->group(function () {
Route::get('/register', [RegisterController::class, 'index'])->name('pos.register');
Route::post('/register/charge', [RegisterController::class, 'charge'])->name('pos.register.charge');
Route::post('/register/mode', [RegisterController::class, 'setMode'])->name('pos.mode.set');
Route::get('/sales', [SaleController::class, 'index'])->name('pos.sales.index');
Route::get('/sales/{sale}', [SaleController::class, 'show'])->name('pos.sales.show');
+15
View File
@@ -253,6 +253,21 @@ class PosRestaurantTest extends TestCase
$this->actingAs($user)->getJson(route('pos.kitchen.feed'))->assertOk()->assertJsonCount(1, 'tickets');
}
public function test_register_mode_toggle_switches_service_style(): void
{
$user = $this->user();
// Switch to restaurant from the register — lands on the floor.
$this->actingAs($user)->post(route('pos.mode.set'), ['style' => 'restaurant'])
->assertRedirect(route('pos.floor'));
$this->assertSame('restaurant', PosLocation::owned($user->public_id)->first()->service_style);
// Back to retail — stays on the register.
$this->actingAs($user)->post(route('pos.mode.set'), ['style' => 'retail'])
->assertRedirect(route('pos.register'));
$this->assertSame('retail', PosLocation::owned($user->public_id)->first()->service_style);
}
public function test_cannot_open_two_tabs_on_one_table(): void
{
$user = $this->user();