With Eloquent you can order results by a JSON column attribute.
// JSON column example:// bikes.settings = {"is_retired": false}$bikes = Bike::where('athlete_id', $this->athleteId) ->orderBy('name') ->orderByDesc('settings->is_retired') ->get();
Tip given by @brbcoding
Enjoyed This Tip?
Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.
Recent Courses
Queues in Laravel 13
18 lessons
1 h 12 min read
[NEW] NativePHP v3: Create Mobile Apps with Laravel
9 lessons
53 min
Livewire v3 to v4: Changes You Need to Know
7 lessons
31 min