Laravel 6 Release New Features and Upgrade

Originally published by Hardik Savani at https://itsolutionstuff.com

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…

Thanks for reading

If you liked this post, share it with all of your programming buddies!

Follow me on Facebook | Twitter

Further reading

PHP with Laravel for beginners - Become a Master in Laravel

Projects in Laravel: Learn Laravel Building 10 Projects

Laravel for RESTful: Build Your RESTful API with Laravel

Fullstack Web Development With Laravel and Vue.js

Laravel 5.8 Tutorial for Beginners

Laravel 5.8 Ajax CRUD tutorial using Datatable JS

Laravel 5.8 Tutorial from Scratch for Beginners

Build RESTful API In Laravel 5.8 Example

Login with Google in Laravel 5.8 App using Socialite Package

Laravel PHP Framework Tutorial - Full Course for Beginners (2019)

Upgrading Laravel To 6.0 From 5.8

#laravel #php #web-development

Laravel 6 Release New Features and Upgrade
29.15 GEEK