PHPackages                             oneduo/laravel-order-by-field - 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. oneduo/laravel-order-by-field

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

oneduo/laravel-order-by-field
=============================

Laravel query builder order by field method

v0.1.0(3y ago)215[2 PRs](https://github.com/oneduo/laravel-order-by-field/pulls)MITPHPPHP ^8.0

Since Feb 22Pushed 2y ago2 watchersCompare

[ Source](https://github.com/oneduo/laravel-order-by-field)[ Packagist](https://packagist.org/packages/oneduo/laravel-order-by-field)[ Docs](https://github.com/oneduo/laravel-order-by-field)[ RSS](/packages/oneduo-laravel-order-by-field/feed)WikiDiscussions main Synced 1mo ago

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

Laravel query builder - order by field
======================================

[](#laravel-query-builder---order-by-field)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4f43b8323643829654896f1c4141db542d38b5b66ebfb2889fc00e16d9f8b50a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6e6564756f2f6c61726176656c2d6f726465722d62792d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/laravel-order-by-field)[![GitHub Tests Action Status](https://camo.githubusercontent.com/410f8dff2be171aa89cdc97730411abcef3d4e96c1d5f9d50efba6c415025bf0/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6c61726176656c2d6f726465722d62792d6669656c642f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/oneduo/laravel-order-by-field/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/2373ed1241a1724eeed2e912654d64375c7e9c9c53c1427e44f5c8148ab1ce40/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6f6e6564756f2f6c61726176656c2d6f726465722d62792d6669656c642f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/oneduo/laravel-order-by-field/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/a1683900840cdff3acfe39eeb8d95b7e0403ab7a174f896d3fb84da9562ffdec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6f6e6564756f2f6c61726176656c2d6f726465722d62792d6669656c642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/oneduo/laravel-order-by-field)

This package adds a `orderByField` macro on the query Builder.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require oneduo/laravel-order-by-field
```

Usage
-----

[](#usage)

```
$keys = [42, 1, 100]
$users = User::query()
    ->whereKey($keys)
    ->orderByField('id', $keys)
    ->get();
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Mikaël Popowicz](https://github.com/mikaelpopowicz)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Unknown

Total

1

Last Release

1175d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cf9fd13f4d32603791fb5ba1796ba8f04c843b99dfa35310ed1499806adc333?d=identicon)[mikaelpopowicz](/maintainers/mikaelpopowicz)

![](https://www.gravatar.com/avatar/fab6b46363863a2d820c53377e8941ede51db95f6680b9bf506ad192652300c8?d=identicon)[Rezrazi](/maintainers/Rezrazi)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![mikaelpopowicz](https://avatars.githubusercontent.com/u/5689944?v=4)](https://github.com/mikaelpopowicz "mikaelpopowicz (2 commits)")

---

Tags

laraveloneduolaravel-order-by-field

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/oneduo-laravel-order-by-field/health.svg)

```
[![Health](https://phpackages.com/badges/oneduo-laravel-order-by-field/health.svg)](https://phpackages.com/packages/oneduo-laravel-order-by-field)
```

###  Alternatives

[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spatie/laravel-model-flags

Add flags to Eloquent models

4301.1M1](/packages/spatie-laravel-model-flags)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[spatie/laravel-sql-commenter

Add comments to SQL queries made by Laravel

1931.4M1](/packages/spatie-laravel-sql-commenter)[spatie/laravel-deleted-models

Automatically copy deleted records to a separate table

409109.8k4](/packages/spatie-laravel-deleted-models)[wnx/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup.

203330.1k2](/packages/wnx-laravel-backup-restore)

PHPackages © 2026

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