aravel 5.6.26 was released June 20th with allowing the passing of the recipient name in mail notifications; the table name is now passed to post-migration create hooks, array/collections are now allowed in Auth::attempt(), and more.
New SQL Connection Lost Messages
First, two new Azure SQL “connection lost” messages were added to DetectsLostConnections. Laravel wasn’t handling dropped connections in workers, which end up getting errors like the following in some cases:
ERROR: SQLSTATE[08S02]: [Microsoft][ODBC Driver 13 for SQL Server]SMux Provider: Physical connection is not usable [xFFFFFFFF].
Recipient Name in Mail Notifications
MailChannel only passes an email address to the Mailer when sending mail notifications. It’s a common situation to also know the notifiable’s name and hence it seems appropriate to include this as the recipient’s name in order to gain trust:
Before this update to Auth::attempt() an array/collection would result in the following query:
select * from`user`
where `email` = 'xxx'
and `user_type` = '1'
and `active` = 'Y'
Laravel released v5.6.25 earlier this month, but the changelog wasn’t finalized until recently, so we’ll cover 5.6.25 in this post! The v5.6.26 release includes new test assertions, macroable database grammars, database grammars are now macroable, and more.
The SQL Server database grammar now has support for using the whereJsonContains method. The reason extra functionality is required for SQL Server 2016+ is as follows:
While MySQL and PostgreSQL expect the binding as a JSON string, SQL Server requires the raw value. This is why we need a separate prepareBindingForJsonContains() method.
The unsetRelation() method allows you to unset a model relationship:
While I can’t think of many use-cases where I’d use this feature, the PR describes a specific need for this:
There are many ways to set and load relationships in Eloquent models. However, it becomes tricky for unsetting an already loaded relation.
I do work a lot in packages which interact with Eloquent and relationships with paradigms such as EAV and others where you have to manipulate relationships directly from traits. I think it’ll be useful to provide as many methods as possible to manage them.
The new hasUser() method adds the ability to determine if the current user is already authenticated without triggering side effects. The Auth::check() method internally calls Auth::user(), which may cause querying the database or make HTTP requests to get the user.
Using hasUser() allows the ability to see if the Auth::guard()->user is already set: