PHPackages                             arneetsingh/laravel-customsort - 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. arneetsingh/laravel-customsort

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

arneetsingh/laravel-customsort
==============================

A package to manually sort records of a eloquent model in custom order

1.0.0(4y ago)15[2 PRs](https://github.com/arneetsingh/laravel-customsort/pulls)MITPHPPHP ^8.1

Since May 19Pushed 2y ago1 watchersCompare

[ Source](https://github.com/arneetsingh/laravel-customsort)[ Packagist](https://packagist.org/packages/arneetsingh/laravel-customsort)[ Docs](https://github.com/arneetsingh/laravel-customsort)[ RSS](/packages/arneetsingh-laravel-customsort/feed)WikiDiscussions main Synced today

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

Manually sort records of a eloquent model in custom order
=========================================================

[](#manually-sort-records-of-a-eloquent-model-in-custom-order)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0990044bf7c4b70420647d452e87a28966a321ceb313fdf0f572e7bf84214058/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61726e65657473696e67682f6c61726176656c2d637573746f6d736f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arneetsingh/laravel-customsort)[![GitHub Tests Action Status](https://camo.githubusercontent.com/9611855a898eebc69946ec5ae3aad9b03871c8dd9bdf1ef1e693deb3a2249380/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f61726e65657473696e67682f6c61726176656c2d637573746f6d736f72742f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/arneetsingh/laravel-customsort/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/24f081021be9d487ede44ccce7e5e7acad4515d86743cc02112833958de6a15b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f61726e65657473696e67682f6c61726176656c2d637573746f6d736f72742f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/arneetsingh/laravel-customsort/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/53071be99f103b7844da9d2d14464bbf5dd6404f43128c44a303a16d3df235a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61726e65657473696e67682f6c61726176656c2d637573746f6d736f72742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/arneetsingh/laravel-customsort)

#### Problem it solves:

[](#problem-it-solves)

Say there is a need to show certain records of posts, eg. featured posts on top in your listing page. Just a custom order set by user to show specific posts in a specific order on top.

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

[](#installation)

You can install the package via composer:

```
composer require arneetsingh/laravel-customsort
```

Publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-customsort-migrations"
php artisan migrate
```

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-customsort-config"
```

Usage
-----

[](#usage)

#### Model

[](#model)

Use the `CanCustomSort` trait in your model you want to have the ability of sorting manually.

```
