定制 lomkit/laravel-rest-api 二次开发

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

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

lomkit/laravel-rest-api

最新稳定版本:v2.17.2

Composer 安装命令:

composer require lomkit/laravel-rest-api

包简介

A package to build quick and robust rest api for the Laravel framework.

README 文档

README

Social Card of Laravel Permission

Laravel Rest Api

Laravel Rest Api is an elegant way to expose your app through an API, it takes full advantage of the Laravel ecosystem such as Policies, Controllers, Eloquent, ...

Requirements

PHP 8.2+ and Laravel 11+

Documentation, Installation, and Usage Instructions

See the documentation for detailed installation and usage instructions.

What It Does

You'll find multiple endpoints exposed when using this package such as mutating, searching, showing, deleting, ...

Here is a quick look at what you can do using API search method:

// POST api/posts/search
{
    "search": {
        "scopes": [
            {"name": "withTrashed", "parameters": [true]}
        ],
        "filters": [
            {
                "field": "id", "operator": ">", "value": 1, "type": "or"
            },
            {
                "nested": [
                    {"field": "user.posts.id", "operator": "<", "value": 2},
                    {"field": "user.id", "operator": ">", "value": 3, "type": "or"}
                ]
            }
        ],
        "sorts": [
            {"field": "user_id", "direction": "desc"},
            {"field": "id", "direction": "asc"}
        ],
        "selects": [
            {"field": "id"}
        ],
        "includes": [
            {
                "relation": "posts",
                "filters": [
                     {"field": "id", "operator": "in", "value": [1, 3]}
                ],
                "limit": 2
            },
            {
                "relation": "user",
                "filters": [
                    {
                        "field": "languages.pivot.boolean",
                        "operator": "=",
                        "value": true
                    }
                ]
            }
        ],
        "aggregates": [
            {
                "relation": "stars",
                "type": "max",
                "field": "rate",
                "filters": [
                    {"field": "approved", "value": true}
                ]
            },
        ],
        "instructions": [
          {
            "name": "odd-even-id",
            "fields": [
              { "name": "type", "value": "odd" }
            ]
          }
        ],
        "gates": ["create", "view"],
        "page": 2,
        "limit": 10
    }
}

Roadmap

  • Metrics support
  • Refactor the response class
  • Alias for includes

统计信息

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

GitHub 信息

  • Stars: 573
  • Watchers: 8
  • Forks: 31
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-07-30