m-finder / giorgio-filter

Laravel query filter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

License

关于 About Giorgio Filter

为你的 Laravel 应用添加一个简化的查询工具。

Add a simplified query tool to your Laravel application.

预览 Preview

安装 Install

引入扩展

Require

composer require wu/giorgio-filter

在你的 Model 类中使用 Filter

Use Filter in your Model class

use GiorgioFilter\Filters\Filter;

注意事项 Considerations

Filter 只能构建 = 条件的查询语句。如果要自定义复杂条件,请像下边代码示例一样自定义 Filter,最后将自定义 Filter 引入到 Model 中。

Filter can only build query with = conditions. If you want to customize complex conditions, please customize the Filter as shown in the code example below, and then import the customized Filter into the your Model.

示例 example:

<?php

namespace App\Models;

use GiorgioFilter\Filters\Filter;
use Illuminate\Database\Eloquent\Builder;

trait UserFilter
{
    use Filter;

    protected function nameFilter($value): Builder
    {
        return $this->builder->where('name', 'like', '%' . $value . '%');
    }
}

可以使用 php artisan make:filter UserFilter 快速创建自定义 Filter。

You can use php artisan make:filter UserFilter to quickly create a custom filter.

License

The Giorgio Socket is open-sourced software licensed under the MIT license.

About

Laravel query filter

License:MIT License


Languages

Language:PHP 100.0%