定制 stobys/laravel-filterable 二次开发

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

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

stobys/laravel-filterable

Composer 安装命令:

composer create-project stobys/laravel-filterable

包简介

The Laravel filterable trait.

README 文档

README

Filterable trait for Laravel models. Slightly inspired by n7olkachev/laravel-filterable.

Version: 1.0.1

How it works

In POST request, it looks for form fields defained in trait property filterable_fields and filter model by them. If model has defained scope with name of form field it uses that scope.

One can use it in this way:

\App\User::filter()->get()

As for now, it can filer collection by three methods - exact filter (is), like filter (like) and range filter (between).

Installation

You can install the package via composer:

composer require stobys/laravel-filterable

Next, add Filterable trait and list all filterable properties:

use Filterable;

protected $filterable_fields = [
	'id'			=> 'is',
	'username'		=> 'like',
	'created_at'	=> 'between',
	'created_after'	=> 'scope'
];

And voila!

Examples

class User extends Model
{
    use Filterable;

    protected $filterable_fields = [
        'id'    => 'is',
        'username'    => 'like',
        'created_at'  => 'between',
        'created_after' => 'scope'
    ];

    public function scopeCreatedAfter($query, $time)
    {
        return $query->where('created_at', '>', $time);
    }
}

License

The MIT License (MIT)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-15

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固