hnhdigital-os/laravel-dynamic-filter

该软件包已被弃用,不再维护。作者建议使用hnhdigital-os/laravel-model-search软件包。

为Laravel的Eloquent模型提供动态属性过滤功能。

dev-master 2018-09-25 00:10 UTC

This package is auto-updated.

Last update: 2022-02-01 13:08:32 UTC


README

#f03c15 此软件包已停用。请考虑使用模型搜索模型搜索组件

提供设置过滤属性和模型关系过滤的能力。

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status StyleCI Test Coverage Issue Count Code Climate

该软件包由澳大利亚精品开发商H&H|Digital开发。访问我们的网站hnh.digital

安装

通过composer

$ composer require hnhdigital-os/laravel-dynamic-filter dev-master

用法

use Bluora\LaravelDynamicFilter\Traits\ModelTrait;

class User extends Model
{
    use ModelTrait;

    /**
     * A nice name for the model.
     *
     * @var array
     */
    protected $filter_name = 'User';

    /**
     * A list of relationships for this model.
     *
     * @var array
     */
    protected $filter_relationships = [
        'Organization' => 'App\Models\Organization'
    ];

    /**
     * A list of attributes that can be used for the advanced filtering trait.
     *
     * @var array
     */
    protected $filter_attributes = [
        'lookup' => [
            'name' => 'Name or email',
            'attribute' => ['first_name', 'last_name', 'email', 'organization.name'],
            'filter' => 'string',
            'search_tab_only' => true,
            'with' => 'organization'
        ],
        'first_name' => ['name' => 'First name', 'attribute' => 'first_name', 'filter' => 'string'],
        'last_name' => ['name' => 'Last name', 'attribute' => 'last_name', 'filter' => 'string'],
        'email' => ['name' => 'Email', 'attribute' => 'email', 'filter' => 'string'],
        'is_active' => ['name' => 'Active user', 'attribute' => 'is_active', 'filter' => 'boolean']
    ];
}

贡献

有关详细信息,请参阅CONTRIBUTING

致谢

许可证

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