承接 jie-anthony/eloquent-filter-in-hyperf 相关项目开发

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

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

jie-anthony/eloquent-filter-in-hyperf

Composer 安装命令:

composer require jie-anthony/eloquent-filter-in-hyperf

包简介

An Eloquent way to filter Eloquent Models

README 文档

README

基于tucker-eric/eloquentfilter 调整为适配Hyperf的模型查询过滤器

安装

composer require jie-anthony/eloquent-filter-in-hyperf -vvv

发布配置

php bin/hyperf.php vendor:publish jie-anthony/eloquent-filter-in-hyperf

命令行创建文件

php bin/hyperf.php gen:eloquent-filter UserFilter

Filter文件

<?php

declare (strict_types=1);
namespace App\ModelFilters;

use JieAnthony\EloquentFilter\ModelFilter;

class UserFilter extends ModelFilter
{
    public function name($name)
    {
        return $this->where('name', 'LIKE', "$name%");
    }

    public function age($age)
    {
        return $this->where('age', $age);
    }
}

模型

<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
use JieAnthony\EloquentFilter\Filterable;

class User extends Model
{
    use Filterable;
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'users';


    public function modelFilter()
    {
        return $this->provideFilter(\App\ModelFilters\UserFilter::class);
    }
}

查询

<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Model\User;
use Hyperf\HttpServer\Annotation\AutoController;

/**
 * @AutoController()
 */
class IndexController extends AbstractController
{

    public function test()
    {
        $params = $this->request->all();
        $data = User::filter($params)->get();
        return [
            'params' => $params,
            'data' => $data
        ];
    }
}

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固