How to sort null values last with Laravel Eloquent

Photo by Konstantin Kleine on Unsplash

Say you have a column called birthday and you want to sort it based on oldest date first. Your Eloquent query for a model called User will look like this:

Great! It worked. But then when you deployed to production, you quickly remembered that birthday is actually an optional field for users and…