PHPackages                             timwassenburg/default-model-order - 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. timwassenburg/default-model-order

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

timwassenburg/default-model-order
=================================

Adds a trait to make your models sortable

v1.0.1(3y ago)245[2 PRs](https://github.com/timwassenburg/default-model-order/pulls)MITPHP

Since Feb 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/timwassenburg/default-model-order)[ Packagist](https://packagist.org/packages/timwassenburg/default-model-order)[ Docs](https://github.com/timwassenburg/default-model-order)[ RSS](/packages/timwassenburg-default-model-order/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (5)Used By (0)

[![Logo](img/banner.png)](img/banner.png)

[![Latest Version on Packagist](https://camo.githubusercontent.com/3f38fa56fb0cc496054f53121c1c03d478ac33d7dce472d871fe15509ab27372/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74696d77617373656e627572672f64656661756c742d6d6f64656c2d6f726465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/timwassenburg/default-model-order)[![GitHub Tests Action Status](https://camo.githubusercontent.com/01d34a560b15c1d9919cfc6bae6843391eb108b1e18e2083089a600204deb97f/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74696d77617373656e627572672f64656661756c742d6d6f64656c2d6f726465722f72756e2d74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/timwassenburg/default-model-order/actions?query=workflow%3Arun-tests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/231396f28379cb78691618a44bc69f60c380129c2c8c196381d669327b2e35d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74696d77617373656e627572672f64656661756c742d6d6f64656c2d6f726465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/timwassenburg/default-model-order)[![License](https://camo.githubusercontent.com/e1bb81cfe10cfaa05f99f018eecdbd0c5c14fe1793cdc90600e4fa759e89b50c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74696d77617373656e627572672f64656661756c742d6d6f64656c2d6f72646572)](https://packagist.org/packages/timwassenburg/default-model-order)

---

Features
--------

[](#features)

This simple package adds a trait to your project that can be used to sort collections of a model by default by a specified column. As a result, the model looks more clean and readable.

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

[](#installation)

Install the package with composer.

```
composer require timwassenburg/default-model-order
```

Usage
-----

[](#usage)

Once you have installed the package, you can import the `DefaultOrder` trait into your model to set the default order. Then, you can assign the desired column to the `$orderBy` variable to order by that column. Additionally, you may optionally set the `$orderDirection` variable to specify the direction of the order, with the default value being `asc`.

```
use TimWassenburg\DefaultModelOrder\DefaultOrder;

class User extends Model
{
    use DefaultOrder;

    protected static string $orderBy = 'name';
    protected static string $orderDirection = 'desc';
}
```

### Publish config (optional)

[](#publish-config-optional)

Suppose you wish to modify the default column name or direction. In that case, you may publish the configuration file to make the necessary adjustments. To do so, run the following command:

```
php artisan vendor:publish --provider="TimWassenburg\DefaultModelOrder\DefaultModelOrderServiceProvider" --tag="config"

```

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

[](#contributing)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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

1223d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/18ef476c8a9d76d44ab65724fb4be330c1c4ce90e2be793bc4628b85bd0d5ba5?d=identicon)[timwass](/maintainers/timwass)

---

Top Contributors

[![timwassenburg](https://avatars.githubusercontent.com/u/75377381?v=4)](https://github.com/timwassenburg "timwassenburg (10 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (4 commits)")

---

Tags

eloquentlaravelmodelsorderbyphpsortabletraitphplaraveleloquenttraitsortablemodels

### Embed Badge

![Health badge](/badges/timwassenburg-default-model-order/health.svg)

```
[![Health](https://phpackages.com/badges/timwassenburg-default-model-order/health.svg)](https://phpackages.com/packages/timwassenburg-default-model-order)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k332.0k1](/packages/cybercog-laravel-love)[cybercog/laravel-nova-ban

A Laravel Nova banning functionality for your application.

42205.7k](/packages/cybercog-laravel-nova-ban)[matchory/elasticsearch

The missing elasticsearch ORM for Laravel!

3064.0k](/packages/matchory-elasticsearch)

PHPackages © 2026

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