discoverydesign/filament-gaze
Composer 安装命令:
composer require discoverydesign/filament-gaze
包简介
See who's viewing a resource in Filament PHP.
README 文档
README
👀 See who's viewing a resource in Filament PHP 🔭
Now supporting FilamentPHP 4 & FilamentPHP 5
Demo
This package allows you to display when other users are viewing the same resource in Filament PHP.
https://packagist.org/packages/discoverydesign/filament-gaze
composer require discoverydesign/filament-gaze
Features
- Ability to see who else is currently viewing a resource.
- Ability to lock a resource to only 1 editor at a time.
- Ability to conditionally allow users to take control of a locked resource.
How to use
- Install the package using
composer require discoverydesign/filament-gaze - Add
\DiscoveryDesign\FilamentGaze\FilamentGazePlugin::make()to your Filament Panel provider.
$panel->plugins([
\DiscoveryDesign\FilamentGaze\FilamentGazePlugin::make()
])
- Publish the assets with
php artisan filament:assets. - Import the package inside your Filament Resource with
use DiscoveryDesign\FilamentGaze\Forms\Components\GazeBanner. - Add the
GazeBannerform component to your form withGazeBanner::make(). - 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('gaze_banner'), // Must be unique to each banner. If you have 2 or more banners in 1 schema, you must pass unique identifiers to them. // ... ]); } // ... }
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('gaze_banner') ->lock() ->canTakeControl(fn() => auth()->user()->isAdmin())
Hiding Gaze Banner on Create Form Example
GazeBanner::make('gaze_banner') ->hidden(fn (?Order $record) => $record === null),
There is also a helper function
GazeBanner::make('gaze_banner') ->hideOnCreate(),
Docs
->pollTimer($timeInSecs)
Description
polltimer can be used to set how often the browser should inform Filament that the user 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 designated controller is the first person to access the resource, or the person who has taken control of the resource. If you enable this after recently 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 (This is only an issue for development).
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.
->hideOnCreate()
Description
hideOnCreate is a helper function that can be used to hide the banner on create forms.
Customization
Change icons
To customize the icons in the banner, you may use the following aliases:
filament-gaze::banner.lockedfor the lock iconfilament-gaze::banner.viewfor the eye icon
Author
discoverydesign/filament-gaze 适用场景与选型建议
discoverydesign/filament-gaze 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 102.76k 次下载、GitHub Stars 达 173, 最近一次更新时间为 2024 年 07 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 discoverydesign/filament-gaze 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 discoverydesign/filament-gaze 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 102.76k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 173
- 点击次数: 27
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-23
