Laravel 6 Release New Features and Upgrade

By Hardik Savani October 12, 2023 Category : PHP Laravel

Laravel introduce new version documentation with laravel 6 new features and upgrade guide. Still not give access of code but as soon as it will be available. laravel 6 gives new feature and some modifications from laravel 5.8.

Some of big new feature i will list here so it can help you when you start using laravel 6 version.

Let's see some new feature from laravel 6 website listed:

1) String & Array Helpers Moved To Package

Laravel 6 have been removed all str_ and array_ helpers functions from by default. laravel 6 introduce new composer package for string and array helpers function. helpers can use the Illuminate\Support\Str and Illuminate\Support\Arr classes.

If you want to use array and string helpers in laravel 6 then you need to use following composer package for helper.

composer require laravel/helpers

2) Carbon 2.0 Supported

In laravel 6, they removed Carbon 1.x version of carbon and they added Carbon 2.0 in laravel 6. So you can read Carbon 2.0 documentation what they added new.

You can read from here: Carbon 2.0.

3) Added cursor method in Eloquent

Laravel 6 added new database eloquent method as cursor(). using cursor() method it will return "Illuminate\Support\LazyCollection" instance.

You can use as like bellow:

$posts = Post::cursor();

foreach ($posts as $post) {

}

4) Update on Eloquent BelongsTo::update Method

In Laravel 6, they give mass assignment protection on belongs to update method. When we are using relation with belongs to then we can update using function. But they not provide mass assignment protection.

In this upgrade, it will provide mass assignment protection. You need to use as like bellow:

/* Without mass assignment protection */

$book->author()->update(['name' => 'Hardik']);

/* With mass assignment protection */

$book->author->update(['name' => 'Hardik']);

5) Declaration Of Primary Key Type

Laravel 6 made this update because of it's improve performance optimizations using set primary key on your model. So basically, if you are using string column data type with primary key then you need to set it on your model as like bellow:

/**

* The "type" of the primary key ID.

*

* @var string

*/

protected $keyType = 'string';

I listed that was good updated.

You can also checkout more upgrade from here: Laravel 6.0 Upgrade

I hope it can help you...

Shares