Laravel 5.7.13 Released


November 8th, 2018

Laravel 5.7.13 Released

Laravel 5.7.13 was released Wednesday with some new collection methods and the ability to return an array of messages in a custom validation rule.

First, new empty collection methods were added, including whenEmpty, whenNotEmpty, unlessEmpty, and unlessNotEmpty. For example, the whenEmpty method will fire this callback on an empty collection:

use Illuminate\Support\Collection;
$collection = new Collection;
$collection->whenEmpty(function ($collection) {
return $collection->push('adam');
$this->assertSame(['adam'], $collection->toArray());

The unless* behave the opposite way:

use Illuminate\Support\Collection;
$collection = new Collection;
$collection->unlessEmpty(function ($collection) {
return $collection->push('adam');
$this->assertSame([], $collection->toArray());

If the collection isn’t empty, the unlessEmpty closure is called:

use Illuminate\Support\Collection;
$collection = new Collection(['user1', 'user2']);
$collection->unlessEmpty(function ($collection) {
return $collection->push('user3');
$this->assertSame(['user1', 'user2, 'user3'], $collection->toArray());

Next, the ability to add an array of validation messages to custom validation rules was added. In a custom validation rule, you can return an array of messages like so:

public function message()
return [
':attribute must be taylor',
':attribute must be a first name'

You can see the full diff between 5.7.12 and 5.7.13 on GitHub, and the full release notes below from the 5.7 changelog.



  • Added ability to return an array of messages in a custom validation rule (#26327)
  • Added whenEmpty/ whenNotEmpty / unlessEmpty / unlessNotEmpty methods to Collection (#26345)
  • Added Illuminate\Support\Collection::some method (#26376, 8f7e647)
  • Added Illuminate\Cache\Repository::missing method (#26351)
  • Added Macroable trait to Illuminate\View\Factory (#26361)
  • Added support for UNION aggregate queries (#26365)


  • Updated AbstractPaginator::appends to handle null (#26326)
  • Added “guzzlehttp/guzzle”: “^6.3”, to composer.json (#26328)
  • Showed exception message on 403 error page when message is available (#26356)
  • Don’t run TransformsRequest twice on ?query= parameters (#26366)
  • Added missing logging options to slack log driver (#26360)
  • Use cascade when truncating table in PostgreSQL (#26389)
  • Allowed pass absolute parameter in has valid signature request macro (#26397)

Changed realization

  • Used Request::validate macro in Auth traits (#26314)

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.