awcodes/recently
Composer 安装命令:
composer require awcodes/recently
包简介
Easily track and access recently viewed records in your filament panels.
README 文档
README
Easily track and access recently viewed records in your filament panels.
Compatibility
| Package Version | Filament Version |
|---|---|
| 1.x | 3.x |
| 2.x | 4.x |
| 3.x | 5.x |
Installation
You can install the package via composer then run the installation command and follow the prompts:
composer require awcodes/recently
php artisan recently:install
Important
If you have not set up a custom theme and are using Filament Panels follow the instructions in the Filament Docs first.
After setting up a custom theme add the plugin's views to your theme css file or your app's css file if using the standalone packages.
@source '../../../../vendor/awcodes/recently/resources/**/*.blade.php';
Usage
The plugin adds a “Recently Viewed” functionality in your filament panel(s), letting users quickly access resources they’ve recently interacted with. It tracks views/visits to EditRecord and ViewRecord pages of resources where it’s enabled.
Registering the plugin
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make(), ]) }
Possible Conflicts
If you are using QuickCreatePlugin or OverlookPlugin you will need to exclude the RecentEntryResource from them.
OverlookPlugin::make() ->excludes([ RecentEntryResource::class, ]), QuickCreatePlugin::make() ->excludes([ RecentEntryResource::class, ]),
Tracking Recent
To record recent edits/views, include the trait on EditRecord or ViewRecord pages of the resources you want to monitor:
Recent Edits:
use Awcodes\Recently\Concerns\HasRecentHistoryRecorder; class EditUser extends EditRecord { use HasRecentHistoryRecorder; protected static string $resource = UserResource::class; }
Recent Views:
class ViewUser extends ViewRecord { use HasRecentHistoryRecorder; protected static string $resource = UserResource::class; }
Configuration
You can enable/disable or customize the plugin's features either globally through the config file or per panel.
// config/recently.php return [ 'user_model' => App\Models\User::class, 'max_items' => 20, 'width' => 'xs', 'global_search' => true, 'menu' => true, 'icon' => 'heroicon-o-arrow-uturn-left', ];
Global Search
By default, the plugin will list the recent visits/views as part of the global search results. To disable this feature, set the global_search option to false from the config or by passing false to the globalSearch() method per panel.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->globalSearch(condition: false), ]) }
Menu
By default, the plugin will list the recent visits/views as a dropdown menu in the topbar using the PanelsRenderHook::USER_MENU_BEFORE render hook. To disable this feature, set the menu option to false in the config or by passing false to the menu() method per panel.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->menu(condition: false), ]) }
Appearance
Icon
Set a custom icon for the menu.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->icon('heroicon-o-clock'), ]); }
Rounded
The menu icon is round you can opt out of this by passing false to the rounded() method.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->rounded(condition: false), ]); }
Label
The menu has no label, but you can set a custom label by passing a string to the label() method.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->label('Recently Viewed Records'), ]); }
Width
The dropdown menu uses the filament dropdown blade component, so you can use any of the options available, the default is xs.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->width('sm'), ]); }
Max Items
Specify the maximum number of recently viewed items to display in the menu.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->maxItems(10), ]); }
Render Hook
The plugin will render the menu using the PanelsRenderHook::USER_MENU_BEFORE hook. However, you can change this using the renderUsingHook() method by providing one of the other available filament Render Hooks.
use Awcodes\Recently\RecentlyPlugin; public function panel(Panel $panel): Panel { return $panel ->plugins([ RecentlyPlugin::make() ->renderUsingHook('PanelsRenderHook::USER_MENU_AFTER'), ]); }
Testing
composer test
Contributing
If you want to contribute to this plugin, you may want to test it in a real Filament project:
- Fork this repository to your GitHub account.
- Create a Filament app locally.
- Clone your fork in your Filament app's root directory.
- In the
/recentlydirectory, create a branch for your fix, e.g.fix/error-message.
Install the plugin in your app's composer.json:
"require": { "awcodes/recently": "dev-fix/error-message as main-dev", }, "repositories": [ { "type": "path", "url": "recently" } ]
Now, run composer update.
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
awcodes/recently 适用场景与选型建议
awcodes/recently 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34k 次下载、GitHub Stars 达 43, 最近一次更新时间为 2024 年 09 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「laravel」 「recently」 「filament」 「awcodes」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 awcodes/recently 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 awcodes/recently 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 awcodes/recently 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Kirby Section to display recently modified content pages
Craft CMS plugin to find recently viewed elements of any type.
Plugin for YOURLS. Default tools to use in some laemmi plugins
Alfabank REST API integration
统计信息
- 总下载量: 34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 43
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-09-04