arielmejiadev/laravel-query-class 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

arielmejiadev/laravel-query-class

Composer 安装命令:

composer require arielmejiadev/laravel-query-class

包简介

it creates query classes to handle easily requests with multiple filters, sorts and includes.

README 文档

README

Latest Version on Packagist Total Downloads GitHub Actions

It generates query classes to handle requests with multiple filters, sorts and includes.

The idea comes as a tip from a LaraconUS 2019 talk from Freek Van der Herten

Installation

You can install the package via composer:

composer require arielmejiadev/laravel-query-class --dev

Stubs & Commands installation

php artisan query-class:install

Usage

php artisan make:query Users/UserQuery --model=User

It would generate a class in app/Http/Queries/Users/UserQuery.php:

You can choose if your query class would extend from Spatie Query Builder (REST API STANDARD) of from an Eloquent query class (for custom cases).

Screen Shot 2021-07-12 at 23 03 53

namespace App\Http\Queries\Users;

use App\Models\User;
use Spatie\QueryBuilder\QueryBuilder;

class UserQuery extends QueryBuilder
{
    public function __construct()
    {
        parent::__construct(User::query());

        $this->allowedFilters('updated_at', 'created_at')
            ->allowedSorts('created_at')
            ->allowedIncludes('team');
    }
}

You can chain any Eloquent method or if you choose Spatie Query Builder methods from both tools.

Now you can inject the Query Class in any controller constructor and the Laravel container will resolve it by itself.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email arielmejiadev@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-07-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固