josespinal/filament-record-navigation
Composer 安装命令:
composer require josespinal/filament-record-navigation
包简介
Record navigation from views
README 文档
README
Introduction
The Filament Record Navigation Plugin allows seamless navigation through records in a Filament resource's view. With this plugin, you can add "Next" and "Previous" buttons to navigate through records efficiently. It includes features like unsaved changes detection, browser history management, and proper URL updates.
Record.Nav.mp4
Features
- Navigate between records with "Next" and "Previous" buttons
- Unsaved changes detection with confirmation dialog
- Browser history management for proper navigation state
- Seamless URL updates without page refresh
- Automatic relation managers refresh when navigating between records
- Support for Laravel 10, 11, and 12
- Compatible with Filament v3.x
Installation
Step 1: Require the package via Composer:
composer require josespinal/filament-record-navigation
The package will automatically register itself.
Step 2: Publish Filament Assets
After installation, you need to publish and build the Filament assets:
php artisan filament:assets
For production environments, make sure to run:
php artisan filament:assets --optimize
Usage
Use the Trait in Your Filament Resource Page
In your Filament resource's EditRecord page, use the HasRecordNavigation trait to add the navigation functionality. And add the action where you want, for example, the header with getHeaderActions:
namespace App\Filament\Resources\PostResource\Pages; use App\Filament\Resources\PostResource; use Filament\Resources\Pages\EditRecord; use JoseEspinal\RecordNavigation\Traits\HasRecordNavigation; class EditPost extends EditRecord { use HasRecordNavigation; protected static string $resource = PostResource::class; protected function getHeaderActions(): array { return array_merge(parent::getActions(), $this->getNavigationActions()); } }
Use with existing actions
If you have existing actions, merge them with the navigation actions, like so:
protected function getHeaderActions(): array { $existingActions = [ // Your existing actions here... ]; return array_merge($existingActions, $this->getNavigationActions()); }
Store Record IDs in Session
In your resource's ListRecords page, include the HasRecordsList trait as follows:
namespace App\Filament\Resources\PostResource\Pages; use App\Filament\Resources\PostResource; use Filament\Resources\Pages\ListRecords; use JoseEspinal\RecordNavigation\Traits\HasRecordsList; class ListPosts extends ListRecords { use HasRecordsList; protected static string $resource = PostResource::class; }
Enable Relation Managers Refresh
To automatically refresh relation managers when navigating between records, use the HasRelationManagersWithRecordNavigation trait in your relation managers:
namespace App\Filament\Resources\PostResource\RelationManagers; use Filament\Resources\RelationManagers\RelationManager; use JoseEspinal\RecordNavigation\Traits\HasRelationManagersWithRecordNavigation; class CommentsRelationManager extends RelationManager { use HasRelationManagersWithRecordNavigation; protected static string $relationship = 'comments'; // Rest of your relation manager code... }
Unsaved Changes Detection
The plugin automatically detects unsaved changes in your forms and will prompt for confirmation before navigating away. This helps prevent accidental data loss when navigating between records.
No additional configuration is needed - this feature works out of the box.
Customizing the Confirmation Message
By default, this uses Filament's translation key filament-panels::unsaved-changes-alert.body. You can customize this message by publishing Filament's translations and modifying the corresponding translation string.
Remember to rebuild your assets after making changes.
Browser Support
The plugin uses modern browser features for enhanced navigation:
- History API for proper browser history management
- URL updates without page refresh
- Works with all modern browsers (Chrome, Firefox, Safari, Edge)
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
josespinal/filament-record-navigation 适用场景与选型建议
josespinal/filament-record-navigation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46.09k 次下载、GitHub Stars 达 31, 最近一次更新时间为 2024 年 05 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Jose Espinal」 「filament-record-navigation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 josespinal/filament-record-navigation 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 josespinal/filament-record-navigation 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 josespinal/filament-record-navigation 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
JWT, JWS and JWE implementation in PHP
JWT, JWS and JWS implementation in PHP
Json Web Token (JWT) Library
JSON Object Signing and Encryption interfaces.
An simple JSON Web Token library for PHP.
Alfabank REST API integration
统计信息
- 总下载量: 46.09k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 21
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-29