Laravel Recipe :D

What are all the new recipes arrived in Laravel 5.5 restaurant

Arun Yokesh
2 min readSep 1, 2017

Are you a foodie?

Is Laravel is your favourite restaurant?

Here are some special recipes you should taste.

Whoops There was an error

Exactly showing where the error occurred in the best way to clear it. Along with exact line of the file. Laravel has improved a lot in debugging.

Page Expiration Detection

“ The Page has expired due to inactivity. Please refresh and try again.” Prevents from the {{csrf_token()}} token expiry or token missing error.

Request Validation

Validation has changed from normal validation to request validation and the normal validation looks like.

$this->validate($request->all(), [
‘title’ => ‘required’
]);

and this is how the request validation is looks like but both are doing the same

request()->validate([
‘title’ => ‘required’
]);

Command “php artisan migrate:fresh”

It drops all the table and creates tables from the first even the migrations table. But when compare to migrate:refresh command it will delete all the tables except migrations table.

Command “php artisan preset”

Preset helps you to create a preset assets to your Laravel application such as vue js, react. If you don’t need any assets? You have a option called none.

Renderable Email Template

In older version of Laravel the templates are not renderable in view but now you can easily render the email template into a function as a return statement like

public function invoice(){
return App\Mail\GenerateInvoice;
}

Command “php artisan make:rule”

You can easy guess this command, yes it’s a custom validation class creating command using this we can easily create a custom rule for our application. Let’s say you need a validation for the phone number and it’s should be maximum 10 characters length and minimum 8 characters length. So using this command you can create a validation class called “ValidateEightToTenLength”

Collection dumping at any stage

There are two ways to dump the data one is dd() and dump(). Now you can dump the data at any stage of your code it ll really help you to debug your code in a better way. When you are using dump for the “n” number then “n” number of collection will display.

$posts->approved()->dump() // first dump->created_today()->dump(); // second dump

Custom blade directives

Laravel 5.5 allows you to create a custom blade directives to use in view files. @if @endif , @foreach @endforeach are some of the pre defined blade directives you know. But now you can create

@verifieduser   Auth::user();@else  Auth::guest();@endverifieduser

Hope you enjoyed the feast 😊

--

--

Arun Yokesh
Arun Yokesh

No responses yet