Package

Discoverydesign Filament Gaze

See who's viewing a resource in Filament PHP.

Package

discoverydesign/filament-gaze

View on GitHub →

Filament Gaze

👀 See who's viewing a resource in Filament PHP 🔭

This package allows you to display when other users are viewing the same resource in Filament PHP.

https://packagist.org/packages/discoverydesign/filament-gaze

How to use

  1. Install the package using composer require discoverydesign/filament-gaze
  2. Add \DiscoveryDesign\FilamentGaze\FilamentGazePlugin::make() to your Filament Panel provider.
$panel->plugins([
    \DiscoveryDesign\FilamentGaze\FilamentGazePlugin::make()
])
  1. Publish the assets with php artisan filament:assets.
  2. Import the package inside your Filament Resource with use DiscoveryDesign\FilamentGaze\Forms\Components\GazeBanner.
  3. Add the GazeBanner form component to your form with GazeBanner::make().
  4. If required, publish the translation files with php artisan vendor:publish --tag=filament-gaze-translations.

Examples

Basic Example

<?php

namespace App\Filament\Resources;

use DiscoveryDesign\FilamentGaze\Forms\Components\GazeBanner;
// ...

class OrderResource extends Resource
{
    // ...

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                GazeBanner::make(),
                    
                // ...
            ]);
    }
    
    // ...
}

Poll Timer Example

GazeBanner::make()
    ->pollTimer(10),

Identifier Example

GazeBanner::make()
    ->identifier('any-order'),

Lock Example

GazeBanner::make()
    ->lock()

Lock With Control Example

GazeBanner::make()
    ->lock()
    ->canTakeControl(fn() => auth()->user()->isAdmin())

Hiding Gaze Banner on Create Form Example

GazeBanner::make()
    ->hidden(fn (?Order $record) => $record === null),

Docs

->pollTimer($timeInSecs)

Description

polltimer can be used to set how often the browser should inform Filament that the use is still viewing the page, along with getting an updated list of other users also viewing. It is advised not to put this value too short, as it can cause rate limiting issues. But also not to have this value too long, as it will result in a delayed update of new users viewing the page.

Arguments

timeInSeconds - (int) The amount of time in seconds between each poll. Default is 30 seconds.

->identifier($fnc)

Description

identifier is used as a unique identifier for this gaze banner. Any other gaze banners with the same identifier will share the same list of active users. This can be useful if you want 2 or more difference resources to share the same list of active viewing users.

Arguments

fnc - (optional, closure | string) The name of the identifier. Default is the resource's model class combines with model Id.

->lock($fnc)

Description

lock can be used to lock the resource for anyone but the current person editing the form. This can be useful if you want to prevent multiple people from editing the same resource at the same time. The controller is the first person to access the resource, or the person who has taken control of the resource. If you enable this after accessing a resource, you may need to run php artisan cache:clear as it is possible that the current cached viewers don't have a marked controller.

Arguments

fnc - (optional, closure | bool) If the resource is lockable or not.

->canTakeControl($fnc)

Description

canTakeControl can be used to allow the user to take control of the resource if it is locked by someone else. This can be useful if you want to allow the user to take control of the resource.

Arguments

fnc - (optional, closure | bool) If the user can take control of the resource. Default is true. If a closure is passed, it should return a bool.

Author

🚀 Discovery Design

Discoverydesign Filament Gaze Related Articles

Filament Gaze: Show When Multiple Users View the Same Resource image

Filament Gaze: Show When Multiple Users View the Same Resource

Read article
Filament through the years image

Filament through the years

Read article
Drop in comments for Filament with Commentions image

Drop in comments for Filament with Commentions

Read article
Handling Bulk Imports in Filament image

Handling Bulk Imports in Filament

Read article
Filament: What to Expect in 2024 image

Filament: What to Expect in 2024

Read article
5 Underrated Filament Features image

5 Underrated Filament Features

Read article

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, they’ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. It’s a clean REST API, so Laravel’s HTTP client is all you need.

Let your users buy domains without leaving your app

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing