wu/giorgio-filter

laravel query filter

1.1.1 2024-03-05 10:01 UTC

This package is auto-updated.

Last update: 2024-05-05 10:26:37 UTC


README

68747470733a2f2f6d2d66696e6465722e6769746875622e696f2f696d616765732f6176617461722e6a706567

68747470733a2f2f696d672e736869656c64732e696f2f62616467652f417574686f722d6d2d2d66696e6465722d726564 68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d352e302d726564 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.