CoreShowPage and automatically restrict form editing to the first user in the queue. It uses Laravel Reverb and presence channels under the hood.
Enabling Presence
Call->enablePresence() on CoreShowPage in your controller. The presence channel is derived automatically from the domain object URL — no frontend configuration needed.
CoreShowPage picks up the enablePresence flag from pageData and activates the usePresence hook automatically.
Form Editing Control
PasspresenceState to CoreForm to restrict editing to the first user in the queue. All other users see a disabled form.
Using the Hook Directly
If you need presence outside ofCoreShowPage, use usePresence directly:
Helper Functions
| Function | Returns |
|---|---|
canEditForm(state) | true if the current user has edit control |
getEditingUser(state) | The user currently holding edit control |
getAllViewers(state) | All users currently viewing |
getUserQueuePosition(state, userId) | The current user’s position in the queue |
How It Works
- When a page loads with presence enabled,
usePresencenormalizes the domain object URL (e.g./orders/123→orders.123) and joins the presence channelcore-page.{normalizedUrl}via Laravel Echo. - The channel broadcasts each user’s ID, name, email, avatar, and join timestamp.
- The first user to join holds edit control. When they leave, the next user in the queue takes over.
- Avatars are displayed in the AppBar — the editing user has a primary ring, viewers have a standard ring.
Troubleshooting
Reverb connection issues
Reverb connection issues
- Verify Reverb is running:
php artisan reverb:start - Check environment variables (
REVERB_APP_ID,REVERB_APP_KEY, etc.).REVERB_APP_KEYmust not contain a dot (.) or colon (:) — those characters break the WebSocket URL and prevent the server connection. - Look for WebSocket errors in the browser console & network tab
- Ensure broadcasting routes are registered in
bootstrap/app.php
Presence not updating
Presence not updating
- Look for
/broadcasting/authcalls in the browser network tab with 200 response- - Look for an authorized socket call to
App.Model.Userin the browser network tab and make sure your authorized to it. - Ensure the user is authenticated
Forms not disabling for other users
Forms not disabling for other users
- Verify
presenceStateis passed toCoreForm - Check
presenceState.userscontains the expected users - Confirm
canEditForm()returns the correct value