Tutorial: Ordering belongsToMany by Pivot

Jason Gilmore has a new tutorial showing a way of ordering belongsToMany relationships by the pivot table.

When declaring a belongsToMany relation in Laravel, you can optionally include the withTimestamps method to indicate the pivot table’s created_at and updated_at columns should be updated whenever a new pivot table record is inserted or updated. But how can you order your query results using one of these columns? In this tutorial, I’ll show you how.

Visit Resource →

Filed in: Laravel Tutorials / Eloquent
Laravel News Partners

Laravel Jobs

Laravel Developer
Remote
Enjin
Senior Laravel Backend Engineer
Remote, USA Only
Kittyhawk.io, Inc.
Senior Laravel Developer
Remote, EU timezones only
Mindbeat
Experienced Laravel Developer
Remote
SolidProfessor
Full Time ad Remote - Experienced Laravel Developer
Europe Only
Thunderbite

Newsletter

Join 31,000+ others and never miss out on new tips, tutorials, and more.