Posted: 21-08-2018

Laravel 5.7 what's new

Laravel 5.7 what's new

A list of new features in Laravel 5.7.

Improved Error Messages for Dynamic Calls

In @laravelphp 5.7 you'll now get a clear, concise message saying that the method doesn't exist on the mode.

Read more at Laravel news.

Coalesce Operator in Blade template

In Laravel 5.7 the Blade “or” Operator is replaced by PHP 7’s Null Coalesce Operator.

//laravel 5.6
$user or "Guest"
//now in 5.7
$user ?? "Guest"

Pagination view customization

Now You can customize the number of pages to show on each side of the current page without having to extend the pagination view-



Email Verification

Optional email verification to the authentication scaffolding is added to the framework. To accommodate this feature, an email_verified_at timestamp column has been added to the default users table migration that is included with the framework.

In order to verify their email, the User model should be marked with the MustVerifyEmail interface. 

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
    // ...


You can use the new verified middleware  in order to protect you routes to only users with verified email

'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class

Add the verified middleware to your route in this way:

Route::get('user/profile', function () {


Laravel Dump Server

Laravel 5.7 offers integration with Symfony's dump-server command via a package by Marcel Pociot.
Now you to dump data to the console or an HTML
To get started, run the dump-server Artisan command:

php artisan dump-server
# Or send the output to an HTML file
php artisan dump-server --format=html > dump.html.


Notification Localization

Laravel now allows you to send notifications in a locale other than the current language, and will even remember this locale if the notification is queued.

$order->notify((new InvoicePaid($invoice))->locale('it'));

or using Facades 

Notification::locale('it')->send($users, new UserCreated($user))


Resources Directory Changes

As announced by Taylor in a tweet , Laravel 5.7 comes  with some little change in the resources directory.

The assets directory will be removed and js and sass directory will be opt out to resources directory.

A full list of new features is available at Laravel 5.7 Release Notes page.

You can also check this nice article on