承接 atnic/eloquent-filters 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

atnic/eloquent-filters

最新稳定版本:2.2.2

Composer 安装命令:

composer require atnic/eloquent-filters

包简介

Laravel 5 Filterable Eloquents.

README 文档

README

Easily filter Laravel Eloquent queries by using URL query strings.

Installation

Install the package via composer

composer require atnic/eloquent-filters

Usage

First you need to add Filterable trait and filters attribute to your model as the following:

use Smartisan\Filters\Traits\Filterable;

class User extends Model
{
    use Filterable;
    
    protected $filters = App\Filters\UserFilter::class;
}

Then create UserFilter class and define your filters as public methods:

use Smartisan\Filters\Filter;

class UserFilter extends Filter
{
    public function status($code)
    {
        return $this->builder->where('status', $code);
    }
}

Note that you are able to access the query builder instance of user by using $this->builder.

Now in order to check for URL query strings and perform the corrosponding filter, you need to use User::filter($request)->get().

Security

If you discover any security related issues, please email mohd.itcs@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-01-10