PHPackages                             jerry58321/model-orderbywith - 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. [Database &amp; ORM](/categories/database)
4. /
5. jerry58321/model-orderbywith

ActiveLibrary[Database &amp; ORM](/categories/database)

jerry58321/model-orderbywith
============================

This is a sorting method for Laravel Eloquent Model relationships.

v1.0.0(2y ago)07MITPHPPHP &gt;=7.2

Since May 31Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Jerry58321/model-orderbywith)[ Packagist](https://packagist.org/packages/jerry58321/model-orderbywith)[ RSS](/packages/jerry58321-model-orderbywith/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

**安裝**
------

[](#安裝)

可以使用 Composer 來安裝 model-orderbywith。請在你的專案目錄中運行以下命令：

```
composer require jerry58321/model-orderbywith

```

**說明**
------

[](#說明)

這個程式庫是 Laravel 中 Eloquent Builder 的擴充方法，能夠透過 Eloquent Relationships 的方式實現關聯排序。

除此之外，它還具備以下優化特點：

1. 可以利用聚合函數進行排序，提供更靈活的排序需求處理方式。
2. 可以在遠程關聯中進行排序，使得在關聯模型之間的遠程關聯中進行排序成為可能。
3. 可以在關聯中加入其他條件，進一步細化關聯排序的範圍和結果。

透過這個程式庫，您可以更有效率且便捷地在使用 Eloquent Builder 進行關聯排序時實現以上功能。

**實際使用方法**
----------

[](#實際使用方法)

[參考單元測試範例](https://github.com/Jerry58321/model-orderbywith/blob/master/tests/OrderByWithTest.php)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

1074d ago

Major Versions

v0.0.1 → v1.0.02023-05-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/9935027189df6f0eddf29a8b546d6360de41d46437d725281159274d1908eaa1?d=identicon)[Hubertwei](/maintainers/Hubertwei)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jerry58321-model-orderbywith/health.svg)

```
[![Health](https://phpackages.com/badges/jerry58321-model-orderbywith/health.svg)](https://phpackages.com/packages/jerry58321-model-orderbywith)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[matanyadaev/laravel-eloquent-spatial

Spatial library for Laravel

3982.9M15](/packages/matanyadaev-laravel-eloquent-spatial)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k7](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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