Filament Gaze: Show When Multiple Users View the Same Resource
Published on by Paul Redmond
Filament Gaze is a plugin for Filament PHP that allows you to display when other users view the same resource. This plugin provides a nice API to make a simple banner or even allow authorized users to take control of a locked page. Here's the most basic example of using Gaze with a form:
public static function form(Form $form): Form{ return $form ->schema([ GazeBanner::make(), // ... ]);}
Main features:
- Quickly display when other users are on the same resource
- Configurable poll time to determine how often it should inform Filament and get a list of users still viewing the page
- Lock a resource
- Allow lock overrides, supporting custom logic
- Conditionally hide the banner
My favorite feature is the canTakeControl()
method, which lets you define custom logic for taking over a page that someone else has control over:
GazeBanner::make() ->lock() ->canTakeControl(fn() => auth()->user()->isAdmin())
Using the above code, the owning user will see that they have control of the page and which other users are on the page. Here's the interface when a user does not have control of a page, but has permission to take control:
You can get started with this package, including full documentation on GitHub at discoverydesign/filament-gaze. This plugin is also listed on the Filament community plugin page.