定制 hayder/navigation-buttons 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hayder/navigation-buttons

最新稳定版本:v1.0.0

Composer 安装命令:

composer require hayder/navigation-buttons

包简介

A Filament plugin to add previous and next navigation buttons to resource pages.

README 文档

README

This Package developed based on this article https://filamentphp.com/content/leandrocfe-navigating-filament-pages-with-previous-and-next-buttons

Navigation Buttons

Navigation Buttons is a simple Laravel package for adding "Previous" and "Next" navigation buttons to Filament resource pages, allowing users to navigate between records easily.

Features

  • Adds "Previous" and "Next" buttons on Filament resource pages.
  • Handles navigation across records in a user-friendly manner.
  • Provides notifications if no previous or next records are available.

Requirements

  • Laravel: ^9.x or ^10.x
  • PHP: ^8.0
  • Filament: ^3.0

Installation

  1. Install the package via Composer:

    Run the following command in your terminal to install the package:

    composer require hayder/navigation-buttons
  2. Publish the configuration file (optional):

    If you wish to customize the package configuration (such as order column or direction), you can publish the configuration file:

    php artisan vendor:publish --tag="navigation-buttons-config"

    This will create a configuration file at config/navigation-buttons.php where you can define your custom settings.

  3. Publish the Translation Files (Optional):

    If you want to customize the button labels or other translation strings, publish the translation files:

    php artisan vendor:publish --tag="navigation-buttons-translations"

Usage

Apply the HasNavigationButtons Trait to Your Filament Resource Page:

In the EditRecord or any other Filament resource page, apply the HasNavigationButtons trait:

namespace App\Filament\Resources\SomeResource\Pages;

use Filament\Resources\Pages\EditRecord;
use App\Filament\Resources\SomeResource;
use Hayder\NavigationButtons\Traits\HasNavigationButtons;
use Hayder\NavigationButtons\Actions\GoToPreviousRecordAction;
use Hayder\NavigationButtons\Traits\HasNavigationButtons;


class EditPage extends EditRecord
{
    use HasNavigationButtons;

    protected static string $resource = SomeResource::class;

    protected function getHeaderActions(): array
    {
        return [
            ...

            GoToPreviousRecordAction::make(),
            GoToNextRecordAction::make(),
        ]
    }
}

The trait will automatically add the "Previous" and "Next" buttons to the resource page header.

Notifications for Navigation:

The package will show a notification if no previous or next record is available.

Example of a notification when there's no next record:

Notification::make()
->title('No next record found')
->danger()
->body('You are already at the last record.')
->send();

Configuration

The package comes with a configuration file that allows you to customize the following:

order_column : The column used to order records for navigation. order_direction : The direction for ordering records (either asc or desc). To modify these settings, publish the configuration file and update the values in config/navigation-buttons.php.

Customization

If you wish to customize the labels for the buttons, you can modify the translation files after publishing them.

return [
    'previous' => 'Previous Record',
    'next' => 'Next Record',
];

License

This package is open-source software licensed under the MIT license.

统计信息

  • 总下载量: 10
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-10-12