Renaming a Column with a Foreign Key in Laravel
This database originally used "customer_id" as the column name for the owner of each row, however the actual model being referenced was a "User". Here's how I changed the name of the column (which happened to have a foreign key on it) via Laravel migration:
For When Things Get Gnarly in Eloquent
Jonathan Reinink has written some excellent content around Eloquent and this article is one that I reference frequently. Jonathan walks us through handling sticky situations when we need to get a single record back from a relationship without causing N+1 issues.
Checking for Duplicate Values in a SQL Table
Today I found myself needing to know if a particular column held unique values. Here's how I accomplished it...