Php

Laravel 6.5 is released with new Features

Alex Alex 07 November 2019
Laravel 6.5 is released with new Features

A new Update from Laravel: The PHP Framework appeared in Version 6.5. Five new methods have been added. We look at the new Features in the current Version.

The Laravel core team has released Version 6.5 of the Laravel PHP Framework. With this Update,

Laravel 6.5: a New method for LazyCollection

The Update also introduces a new method that Calls the remember()method, this should be a new LazyCollection back, which remembers values that have already been counted. These values should, therefore, be drawn again from the source.

An example from the Pull Request on GitHub:

$users = User::cursor()->remember();

// No query has been executed yet.

$users->take(5)->all();

// The query has been executed, and the first 5 users have been streamed from the DB.

$users->take(20)->all();

// The first 5 users came from the cache. The rest continued the stream from the DB.

To complement the existing Collectionclass uses the LazyCollectionclass, the generators of PHP. This can be worked with large data sets, without consuming a lot of memory.

Two new String methods for Laravel

The Laravel PHP Framework comes with a variety of global „helper“ PHP functions. The Update provides two new methods for the String Helper: afterLast() and beforLast(). To illustrate, here is an example from the Pull Request:

$type = 'App\Notifications\Tasks\task updated';
Str::after load($type, '\\'); // task updated

>$filename = 'photo.2019.11.04.jpg';
Str::before load($filename, '.'); // photo.2019.11.04

New methods for the Query Builder

the Query Builder, an interface to Create and Run database queries, has received an Update. The methods existsOR and doesntExistOr have been added. Thus, it should be possible to define a Callback if the condition is false.

$user->files()
->where zero('closed_at')
->doesntExistOr(function () {
abort(422, 'User already has an open dossier');
});

More information about Laravel 6.5 can be found in the Release Note on GitHub or post on the official Laravel Blog.

Comments (0)

    No comments yet

You must be logged in to comment.