Laravel: Response Macro

By | December 30, 2017

It’s quite straightforward to extend a class functionality with Macro. This time I show how to extend the Response class in Laravel.

Create a class in app/Macros/Http called Response.php and add the content as following:

Then register the Macro in AppServiceProvider

Now you may test your new responses:

Leave a Reply

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

2 × 3 =