Eloquent, order by relationship and eager loading

This question comes up now and again. How to order a query results on a one-to-one relationship in Eloquent. Since ´with()´ is creating another query Eloquent does not know about...

Eloquent, Postgres, UUIDs and not getting id's back

Postgres has an excellent column type for using UUIDs as primary keys. The UUIDs are generated default by Postgres. There is a small caveat working with UUIDs as primary keys...

Eloquent migration after

This is a simple little trick for adding columns to an existing table. For obvious reasons, you cannot use after() to a column created for your migration. However, the...

Eloquent get() vs chunk() vs lazy() benchmarks

I did some unscientific benchmarks of the methods available in Laravel. Even the official documents describe the characteristics of each technique, I wanted a quick ”ballpark benchmark” of which one...

Select all checkboxes with Alpine.js

UPDATED 2021-12-03 Using the document.querySelectorAl to manipulate the DOM directly is not a good way to do this. Instead have array which contains all the availabe items. A...