Laravel 5.5.33 Is Now Available, Learn About What’s in the New Release

News

January 31st, 2018

laravel-5.5.33.png

Laravel 5.5.33 is now available as of Monday, January 29th with some excellent convenience methods ranging from the query builder to collections and testing.

First up Jonathan Reinink added a “not exists” method to the query builder which is named doesntExist():

1User::where('email', 'user@example.com')->doesntExist();

Roberto Aguilar added a new test response assertion assertHeaderMissing() that is the inverse of the assertHeader():

1$response->assertHeaderMissing('Location');

The Illuminate\Support\Collection now has a new higher order unique(), which was contributed by Justin Seliga:

Here’s an example from a php artisan tinker session if you want to experiment:

1use \Illuminate\Support\Collection;
2>>> $c = new Collection([
3... ['id' => '1', 'name' => 'first'],
4... ['id' => '1', 'name' => 'second'],
5... ['id' => '3', 'name' => 'third'],
6... ]);
7>>> $c->unique->id
8=> Illuminate\Support\Collection {#751
9 all: [
10 0 => [
11 "id" => "1",
12 "name" => "first",
13 ],
14 2 => [
15 "id" => "3",
16 "name" => "third",
17 ],
18 ],
19 }

A Boolean toggle was added to withTrashed() by Kuba Szymanowski, which decides whether or not to included trashed records:

1Model::withTrashed(true)->get(); // Retrieves trashed records
2Model::withTrashed(false)->get(); // Does not retrieve trashed records

The use-case is to avoid a splitting control flow, but you can continue to use withTrashed() without passing any arguments. Here’s an example to further understand the change:

1// New use-case
2public function index(Request $request)
3{
4 return User::withTrashed($request->showDeleted)->get();
5}
6
7// Before pre-5.5.33, you can continue to do this...
8public function index(Request $request)
9{
10 $query = User::query();
11
12 if ($request->showDeleted) {
13 $query->withTrashed();
14 }
15
16 return $query->get();
17}

Here are the full release notes for Laravel 5.5.33:

v5.5.33 (2018-01-30)

Added

  • Added notExists() method to query builder (#22836, 9d2a7ca)
  • Added assertHeaderMissing() assertion (#22849, #22866)
  • Added support for higher order unique (#22851)
  • Added boolean toggle to withTrashed() (#22888)

Changed

  • Support Mix HMR with different host/port (#22826, 24897d6)
  • Make route filtering by method case-insensitive (#22856)
  • Added missing PostgreSQL operator for array overlap (#22903)

Filed in:

Paul Redmond

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