How to Master New In Laravel 7 in 8 Simple Steps

Here are the new features in laravel 7 on March 3rd, 2020 including

  • Laravel Airlock
  • Custom Eloquent Casts
  • Blade Component Tags & Improvements
  • HTTP Client
  • Route Caching Speed Improvements
  • Fluent String Operations
  • Multiple Mail Drivers
  • Artisan test Command

Laravel Airlock

This new feature in laravel provide a  featherweight authentication system for

  • SPAs (Single page applications)
  • simple, token based APIs
  • mobile applications

this feature allows user to generate multiple Api tokens these token may be granted abilities/scop to perform the necessary action which are allowed to perform and validate requests.

Custom Eloquent Casts

In order to define your own cast type this feature is very helpful. In order to use this you must implements your class with CastsAttributes interface. Classes that implement this interface must define a get and set methods.

get  method is use to cast raw value from database to a cast valeu
st method is cast raw value to value insert in database (e.g json) 

namespace App\Casts;
use Illuminate\Contracts\Database\Eloquent\CastsAttributes;

class MyTestJson implements CastsAttributes
 public function get($model, $key, $value, $attributes)
        return json_decode($value, true);
public function set($model, $key, $value, $attributes)
        return json_encode($value);



Once you have defined a custom cast type, you may attach it to a model attribute using its class name


namespace App;

use App\Casts\MyTestJson ;
use Illuminate\Database\Eloquent\Model;

class User extends Model
    protected $casts = [
        'options' => MyTestJson ::class,

Blade Component Tags & Improvements

New methods will available  App\View\Components\Alert  
the component may be managed using the automatically included $attribute variable, which is an attribute bag instance.

component may be rendered in another Blade view using the component’s tag

<x-alert type="error" class="mb-4">
    <x-slot name="heading">
        Alert content...
    Default slot content...

HTTP Client

In order to make quick request Http response through API’s now become easier with minimal code around the Guzzle HTTP client,  Example for post request.

use Illuminate\Support\Facades\Http;

$response = Http::withHeaders([
    'h1' => 'foo',
    'h1' => 'bar'
])->post('', [
    'name' => 'Suraj',

return $response['id'];

For Http response

    // Stub a JSON response for GitHub endpoints...
    '*' => Http::response(['foo' => 'bar'], 200, ['Headers']),
'*' => Http::response('Hello World', 200, ['Headers']),

Fluent String Operations

Laravel 7 provide object-oriented, fluent string manipulation . You may create a fluent Illuminate\Support\Stringable

return (string) Str::of('  Suraj tester ')
                    ->replace('tester', 'Developer')

Multiple Mail Drivers

Now in laravel 7 you can configure multiple mail configuration and use as for multiple mail drivers stored in different mail configurations of your app. Laravel use the default mailer in mail configuration

        ->send(new SendDetails($order));

Route Caching Speed Improvements

New method was introduced in laravel 7 as route:cache which is very useful in very large applications having 800 or more routes and results in 2X speed

Artisan test Command

The test command was contributed by Nuno Maduro.

In addition to the phpunit command, you may now use the test Artisan command to run your tests. 

Read More documentation on official website of Laravel for previous version you can read more docs here

You may also like...

41 Responses

  1. BrianArida says:

    You’ve got terrific stuff in this article.

  2. BrianArida says:

    Pretty interesting, look forth to returning.

  3. tҺe website іѕ really good, I like your site!

  4. First time visiting your website, I enjoy your website!

  5. JamesVic says:

    Extremely user pleasant site. Immense info offered on few clicks.

  6. First time visiting your website, I really like your blog!

  7. I was pretty pleased to discover this site. I want to to thank you for your time for this fantastic read!! I definitely liked every bit of it and i also have you saved to fav to look at new things on your blog.

  8. Sixta Atay says:

    First time visiting your website, I like your web site!

  9. g says:

    Hello everyone, it’s my first go to see at this web site, and paragraph is truly fruitful in favor
    of me, keep up posting these content.

  10. g says:

    It’s an remarkable article designed for all the web
    users; they will take advantage from it I am sure.

  11. g says:

    It’s really a nice and useful piece of info. I am glad that you simply shared this
    useful info with us. Please keep us up to date like this.
    Thank you for sharing.

  12. I enjoy reading a post that can make people think. Also, many thanks for allowing for me to comment!

  13. Investments says:

    bookmarked!!, I love your blog!

  14. I would like to thank you for the efforts you’ve put in penning this site. I really hope to view the same high-grade content by you later on as well. In fact, your creative writing abilities has inspired me to get my own blog now 😉

  15. After I originally left a comment I seem to have clicked the -Notify me when new comments are added- checkbox and from now on every time a comment is added I recieve 4 emails with the same comment. There has to be a way you are able to remove me from that service? Kudos!

  16. Saved as a favorite, I love your web site!

  17. indian visa says:

    I was able to find good information from your blog posts.

  18. This site really has all of the information and facts I needed about this subject and didn’t know who to ask.

  19. I couldn’t refrain from commenting. Perfectly written!

  20. You’re so interesting! I don’t believe I have read through anything like that before. So great to discover someone with a few genuine thoughts on this issue. Really.. many thanks for starting this up. This website is something that is required on the web, someone with some originality!

  21. A fascinating discussion is definitely worth comment. I believe that you need to publish more on this topic, it may not be a taboo matter but typically people do not discuss such topics. To the next! Best wishes!!

  22. This site was… how do you say it? Relevant!! Finally I have found something that helped me. Thanks!

  23. I’m impressed, I have to admit. Rarely do I come across a blog that’s equally educative and entertaining, and let me tell you, you have hit the nail on the head. The issue is something which not enough men and women are speaking intelligently about. Now i’m very happy I found this in my hunt for something relating to this.

  24. gox scooter says:

    Greetings, I believe your site might be having browser compatibility problems. When I take a look at your website in Safari, it looks fine however when opening in I.E., it’s got some overlapping issues. I merely wanted to give you a quick heads up! Other than that, fantastic site!

  25. Blogger Task says:

    I’m extremely pleased to find this website. I wanted to thank you for your time for this wonderful read!! I definitely really liked every part of it and i also have you book marked to look at new things on your web site.

  26. Foot Ball says:

    That is a good tip particularly to those new to the blogosphere. Simple but very accurate info… Thank you for sharing this one. A must read article!

  27. Serene Media says:

    There is certainly a lot to find out about this subject. I like all of the points you made.

  28. You made some really good points there. I looked on the internet for more information about the issue and found most individuals will go along with your views on this web site.

  29. You’re so interesting! I do not believe I’ve read through a single thing like this before. So wonderful to discover someone with genuine thoughts on this topic. Seriously.. thanks for starting this up. This web site is one thing that’s needed on the web, someone with some originality!

  30. You’ve made some good points there. I checked on the internet for more info about the issue and found most individuals will go along with your views on this site.

  31. A fascinating discussion is definitely worth comment. I do believe that you should publish more on this subject matter, it may not be a taboo subject but usually people do not talk about such issues. To the next! Kind regards!!

  32. This is a topic that is near to my heart… Thank you! Exactly where are your contact details though?

  33. Very good post! We are linking to this particularly great post on our site. Keep up the good writing.

  34. Shanel says:

    Hi, I do think this is a great site. I stumbledupon it 😉 I’m going to come back yet again since i have bookmarked it.

    Money and freedom is the greatest way to change, may you be rich and continue to guide others.

  35. Greetings! Very helpful advice in this particular post! It is the little changes that produce the most significant changes. Thanks for sharing!

  36. 18+ says:

    You’ve made some really good pointss there. I looke on the net
    for more info about the issue and found most people will go along with your viewss
    on this site.

  37. Very helpful! Is there anything further I should know next? Or is this a good start?

  38. I understand what you’re saying, but I want some detail. Is it ok if we talk more?

  39. Pretty! This was a really wonderful article. Thanks for providing this information.

  40. I really like reading a post that can make people think. Also, thanks for permitting me to comment!

  41. This is a topic that is close to my heart… Best wishes! Exactly where are your contact details though?

Leave a Reply

Your email address will not be published. Required fields are marked *

You have successfully subscribed to the newsletter

There was an error while trying to send your request. Please try again.

codeforbetter will use the information you provide on this form to be in touch with you and to provide updates and marketing.