Comparing model equality in Laravel
This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.
Dropping in Laravel 5.3 is an easy way to compare if two model instances you've got represent the same record in your database. The new is()
method checks to see if the model keys, table and connection names match up.
For more information, see the relevant pull requests: #14281 and #14316.
A blog about Laravel & Rails by Dwight Watson;
- building Roomies, myInspections & High School Notes.
- previously myRent & Flatmates.