lifeonscreen/nova-sort-relations

此软件包提高了Laravel Nova中关系排序的支持。

v0.0.2 2019-03-11 08:04 UTC

This package is auto-updated.

Last update: 2024-08-29 04:03:46 UTC


README

此软件包提高了Laravel Nova中关系排序的支持。

安装

使用composer安装

$ composer require lifeonscreen/nova-sort-relations

使用方法

LifeOnScreen\SortRelations\SortRelations特性包含到您的类中。通过覆盖indexQuery定义基本(基础)查询。在$sortRelations数组中定义可排序的列。

...
use LifeOnScreen\SortRelations\SortRelations;
...

class Product extends Resource
{
    public static $sortRelations = [
        // overriding id with product.id (this prevent ambiguous id, if you select multiple ids)
        'id'               => 'product.id',
        // overriding user relation sorting
        'user'         => [
            // sorting multiple columns
            'users.name',
            'users.surname',
        ],
        // overriding company relation sorting
        'company'          => 'company.name',
    ];
    
    public static function indexQuery(NovaRequest $request, $query)
    {
        // You can modify your base query here.
        return $query;
    }
}

安全

如果您发现任何与安全相关的问题,请通过电子邮件联系作者,而不是使用问题跟踪器。

致谢

许可

MIT许可。有关更多信息,请参阅许可文件