PHPackages                             chenyansong/response-transformation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. chenyansong/response-transformation

ActiveLibrary

chenyansong/response-transformation
===================================

Conversion response of user defined model based on laravel

0.0.2(4y ago)010MITPHPPHP ^7.3

Since Apr 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/bukeliyuchenmou/responseTransformation)[ Packagist](https://packagist.org/packages/chenyansong/response-transformation)[ RSS](/packages/chenyansong-response-transformation/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

responseTransformation
======================

[](#responsetransformation)

Conversion response of user defined model based on laravel
基于laravel的自定义模型转换响应

备注
--

[](#备注)

有点像dingo-api的转换层

开始
--

[](#开始)

发布配置文件

```
    php artisan wdnmd:publish
```

定义模型转换层
-------

[](#定义模型转换层)

- modelName 是允许访问的关联项
- modelTransForm 是子关联的模型转换层映射类
- handle 是返回的模型数据
- installType 更多的 install是根据配置文件里的query\_key来的

```
namespace App\Transformation;

use App\Models\User;
use Illuminate\Database\Eloquent\Model;
use Wdnmd\Transform;

class UserTransform extends Transform
{
    protected $modelName = ['type'];

    protected $modelTransForm = ['type' => TypeTransform::class];

    public function handle(Model $user) {
        return [
            'name' => $user->name
        ];
    }

    public function installType($user)
    {
        return $this->item($user->getType, new TypeTransform());
    }
}
```

关联
--

[](#关联)

```
支持以传参的方式来访问关联，使用符号.可以找下一级关联，使用符号,可以查找当前不同的关联

```

约定
--

[](#约定)

```
模型中的关联以get开头后面的驼峰命名的方式，然后在使用query查询时候，可以使用以下划线小写分割的形式

```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~70 days

Total

2

Last Release

1769d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f1ad4f647162da2b4389a3f86cda3f67f90b7f9ccb8ee9563e042ccf999ee0db?d=identicon)[1370571528@qq.com](/maintainers/1370571528@qq.com)

---

Top Contributors

[![bukeliyuchenmou](https://avatars.githubusercontent.com/u/38170690?v=4)](https://github.com/bukeliyuchenmou "bukeliyuchenmou (26 commits)")

### Embed Badge

![Health badge](/badges/chenyansong-response-transformation/health.svg)

```
[![Health](https://phpackages.com/badges/chenyansong-response-transformation/health.svg)](https://phpackages.com/packages/chenyansong-response-transformation)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
