Laravel Sort is a good package to sort Eloquent model records by their attributes or relationships.

Relationship types that can be sorted by: hasOne, belongsTo

laravel sort

Installation

Install the package via Composer:

composer require zbiller/laravel-sort

Source Code

https://github.com/zbiller/laravel-sort