Skip to content

Instantly share code, notes, and snippets.

View ariefhikam's full-sized avatar

Arief Hikam ariefhikam

View GitHub Profile
@ariefhikam
ariefhikam / index.php
Last active August 6, 2019 12:25
Laravel Sorting from another table with Eloquent
/*
By: Arief Hikam
Laravel Sorting from another table with Eloquent
Sometimes it is difficult to perform sorting by Eloquent because relationships do not use the JOIN in query builder but use
Eager Load which mean we can not sorting by another table field because the field is doesn't exist.
This is how we use the simple code Eloquent and sorting another table by using LEFT JOIN.
I think this is the simplest way I can think of.