Reading List
Comparing two database columns in Laravel from Sebastian De Deyne RSS feed.
Comparing two database columns in Laravel
When you want to compare two database columns in Laravel, you can’t use where
because it treats the argument you’re comparing to as a value.
Instead, Laravel has a whereColumn
method you can use to compare a value to another column’s value.
// Retrieve posts that were updated after
// they were published.
Post::query()
->whereColumn('updated_at', '>', 'published_at')
->get();