naxon/nova-field-sortable
最新稳定版本:v1.0.4
Composer 安装命令:
composer require naxon/nova-field-sortable
包简介
A Laravel Nova field.
README 文档
README
Description
This field adds reordering functionality to your resource's index using the awesome eloquent-sortable package by the great people of Spatie.
Requrements
- Laravel 5.6+ with Nova.
- spatie/eloquent-sortable (If not already installed, this package will install if for you and all you have to do is follow the installation instructions).
Installation
This package can be installed through Composer.
composer require naxon/nova-field-sortable
Usage
- Follow the usage instructions on the eloquent-sortable repository to make your model sortable.
- Use the
Naxon\NovaFieldSortable\Concerns\SortsIndexEntriestrait in your Nova Resource. - Add a public static property called
$defaultSortFieldto your resource, containing your sorting column (I recomment adding it in your mainapp/Nova/Resource.phpfile). - Add the
Naxon\NovaFieldSortable\Sortablefield to your Nova Resourcefieldsmethod, using a label and your primary key column.
Example
<?php namespace App\Nova; use Laravel\Nova\Fields\ID; use Illuminate\Http\Request; use Laravel\Nova\Http\Requests\NovaRequest; use Laravel\Nova\Fields\Text; use Naxon\NovaFieldSortable\Concerns\SortsIndexEntries; use Naxon\NovaFieldSortable\Sortable; class Page extends Resource { use SortsIndexEntries; public static $defaultSortField = 'sort_order'; /** * Get the fields displayed by the resource. * * @param \Illuminate\Http\Request $request * @return array */ public function fields(Request $request) { return [ ID::make()->sortable(), Text::make('Title'), Sortable::make('Order', 'id') ->onlyOnIndex(), ]; } }
Security
If you discover any security related issues, please email naxond@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 270.31k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 59
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-09
