承接 jwohlfert23/laravel-api-query 相关项目开发

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

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

jwohlfert23/laravel-api-query

最新稳定版本:5.1.0

Composer 安装命令:

composer require jwohlfert23/laravel-api-query

包简介

Provides laravel scope to build query from request query params

README 文档

README

Installation

composer require jwohlfert23/laravel-api-query

Usage

This package is implemented as a trait, which provides the buildFromRequest scope.

use Jwohlfert23\LaravelApiQuery\BuildQueryFromRequest;

class Post {
    use BuildQueryFromRequest;
}
Post::buildFromRequest()->get();

?sort=-id,name

is the same as:

Post::orderByDesc('id')->orderBy('name');

?filter[name]=Bobby&filter[author.name][contains]=Bob

is the same as:

Post::where('name', 'Bobby')->whereHas('author', function($q) {
    $q->where('name', 'like', '%Bob%');
});

Note: this package doesn't use "whereHas", but rather performs left joins internally. However, the results should be the same as the above code.

Filters default to using the "equal" operator. These are the operators available to use in filtering (contains is use above).

  • eq (=)
  • gt (>)
  • gte (>=)
  • lt (<)
  • lte (<=)
  • contains

?with=author,comments

is the same as

Post::with('author','comments');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-05-08