Laravel 6.5 is released with new features

Laravel 6.5 is released with new features
2 min read
13 November 2019

Laravel core team has released version 6.5 of the PHP framework Laravel. This update introduces several new methods for the LazyCollection, the String Helper and the Query Builder.

Laravel 6.5: New method for LazyCollection

The update introduces a new method: When you call remember() method, it should return a new LazyCollection that remembers values that have already been enumerated. These values should therefore not be pulled from the source again.

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 Collection class, the LazyCollection class uses PHP generators. This allows to work with large datasets without using too much memory.

Two new string methods for Laravel

The PHP-Framework Laravel brings along a multitude of global "helper" PHP functions. The update provides two new methods for the string helper: afterLast() and beforLast().  To illustrate this, here is an example from the Pull Request:

$type = 'App\Notifications\Tasks\TaskUpdated';
Str::afterLast($type, '\\'); // TaskUpdated

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

New methods for the Query Builder

The Query Builder is an interface for creating and executing database queries, has also been updated. The methods existsOR and doesntExistOr have been added. This should make it possible to define a callback if the condition is false.

    ->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 the post on the official Laravel blog.

Alex 10.6K
Joined: 4 years ago
In case you have found a mistake in the text, please send a message to the author by selecting the mistake and pressing Ctrl-Enter.
Comments (0)

    No comments yet

You must be logged in to comment.

Sign In / Sign Up