Comparing model equality in Laravel

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.

if (auth()->user()->is($post->author)) {
    // The currently authenicated user is the author of the post.
}

For more information, see the relevant pull requests: #14281 and #14316.