Get expert guidance in a few days with a Laravel code review

Laravel 5.6.26 Released

Published on by

Laravel 5.6.26 Released image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

Laravel 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:

hello@example.org
vs
John Doe <hello@example.org>

Here’s an example from the pull request tests:

public function routeNotificationForMail($notification)
{
return [
$this->email => $this->name,
'foo_'.$this->email,
];
}

Post-Migration Table Name in Callbacks

Next, the table name is now passed to post-migration callbacks:

app('migration.creator')->afterCreate(function ($table) {
//
});

Allowing Arrays and Collections in Auth::attempt()

Arrays and collections are now allowed in an Auth::attempt() call. From the pull request, you’re arrays/collections will be converted to a “where in()” condition:

Auth::attempt([
'email' => $request->get('email'),
'password' => $request->get('password'),
'user_type' => collect([1, 2, 3]),
'active' => 'Y'
], $request->get('remember'))

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'
limit 1

Laravel 5.6.25

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.

Builder::whereJsonContains()

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.

Model::unsetRelation()

The unsetRelation() method allows you to unset a model relationship:

$model->unsetRelation('user');

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.

Auth::hasUser()

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:

public function getLikedAttribute()
{
return Auth::hasUser() ? ! is_null($this->likeByCurrentUser) : null;
}

TestResponse::assertOk()

The new assertOK() method is syntactic sugar for asserting that a response returned a 200 status code:

$response->assertStatus(200);
$response->assertOk();

Changelog

Here’s the full changelog for both 5.6.25 and 5.6.26:

v5.6.26 (2018-06-20)

Added

  • Added two Azure SQL server connection lost messages (#24566)
  • Allowed passing of recipient name in Mail notifications (#24606)
  • Started passing table name to the post migration create hooks (#24621)
  • Allowed array/collections in Auth::attempt method (#24620)

Changed

  • Prevent calling the bootable trait boot method multiple times (#24556)
  • Make chunkById() work for non-incrementing/non-integer ids as well (#24563)
  • Make ResetPassword Notification translatable (#24534)

v5.6.25 (2018-06-12)

Added

  • Added whereJsonContains() to SQL Server (#24448)
  • Added Model::unsetRelation() (#24486)
  • Added Auth::hasUser() (#24518)
  • add assertOk() response assertion (#24536)

Changed

  • Set the controller name on the action array when callable array syntax is used (#24468)
  • Make database grammars macroable (#24513)
  • Allow “app” migrations to override package migrations (#24521)
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
A new beta of Laravel Wayfinder just dropped image

A new beta of Laravel Wayfinder just dropped

Read article
Ben Bjurstrom: Laravel is the best Vibecoding stack for 2026 image

Ben Bjurstrom: Laravel is the best Vibecoding stack for 2026

Read article
Laravel Altitude - Opinionated Claude Code agents and commands for TALL stack development image

Laravel Altitude - Opinionated Claude Code agents and commands for TALL stack development

Read article
JSON:API Resource in Laravel 12.45 image

JSON:API Resource in Laravel 12.45

Read article
Caching With MongoDB for Faster Laravel Apps image

Caching With MongoDB for Faster Laravel Apps

Read article
Laravel 12.44 Adds HTTP Client afterResponse() Callbacks image

Laravel 12.44 Adds HTTP Client afterResponse() Callbacks

Read article