定制 hassanalisalem/querybuilder 二次开发

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

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

hassanalisalem/querybuilder

Composer 安装命令:

composer require hassanalisalem/querybuilder

包简介

This package is used to build a query from jQuery Query builder plugin rules.

README 文档

README

jQuery Query Builder

this package is to build query form jQuery Query Builder library, it works with laravel models, and it uses the model relations. Also it hide your table structure, so you dont need to name the filters as your table columns

Structure

Install

Via Composer

$ composer require hassanalisalem/querybuilder

Usage

in your controller or whatever place you are building your query

use hassanalisalem\querybuilder\Query;
...
...

$model = new User();
$rules = $request->rules; // rules from the jQuery query builder form.
$query = Query::build($model, $rules);
// you can use it as: $query->get() to get the query result
// or to check the query string: $query->toSql()

in the model

you should define a public array variable named filterable. This should contain all your filters as filter id or key (from the jquery query builder filters) => filter value.

incase of ambiguous key you can add "as". so if I have table named industries and I want to query whereIn('id', [])... so the key should be 'filter_name_industries' => 'industries.id as industries'

public $filterable = [
    'filter_name' => 'this.name',
    'filter_user_post_title' => 'posts.title',
    'filter_user_post_comment' => 'posts.comments.text',
    'filter_industry' => 'industries.id as industries', // if there is ambiguous key.
    // it is recommended to prepend the key with 'filter_'
];

this means that the name source is the model itself. posts means that the title is from another relation named posts (posts) should be a function in the model that returns a relation.. also comments is a function in Post that returns a relation..

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-04-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固