定制 ctrlwebinc/nova-order-field 二次开发

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

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

ctrlwebinc/nova-order-field

最新稳定版本:2.1.0

Composer 安装命令:

composer require ctrlwebinc/nova-order-field

包简介

A Laravel Nova field.

README 文档

README

Latest Version on Packagist Total Downloads

Description

A field that adds reordering functionality to your Laravel Nova resource's index using the eloquent-sortable package by Spatie.

Installation

This package can be installed through Composer.

composer require ctrlwebinc/nova-order-field

Usage

  1. Follow the usage instructions on the eloquent-sortable repository to make your model sortable.
  2. Add the Ctrlweb\NovaOrderField\Orderable trait to your Nova Resource.
  3. Add a public static property called $defaultOrderField to your resource, containing your order column.
  4. Add the OrderField to your Nova Resource fields method.

Grouping

If your model/table has a grouping field (usually a foreign key): id, user_id, title, order_column and you'd like the above methods to take it into considerations, you can create a buildSortQuery method at your model:

public function buildSortQuery()
{
    return static::query()->where('user_id', $this->user_id);
}

This will restrict the calculations to fields value of the model instance.

Example

use Ctrlweb\NovaOrderField\Orderable;
use Ctrlweb\NovaOrderField\OrderField;

class Page extends Resource
{
    use Orderable;
    
    public static $defaultOrderField = 'order';
    
    public function fields(Request $request)
    {
        return [
            OrderField::make('Order'),
        ];
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-08-15