Looking to hire Laravel developers? Try LaraJobs

laravel-macros-response-customised maintained by abdulnizam

Description
Customised Response Macro's for Laravel
Author
Last update
2018/07/22 06:29 (dev-master)
License
Downloads
8

Comments
comments powered by Disqus

laravel-macros-response-customised

laravel package to control the response and customise the dataname as per the requirement.

Installation

This package can be installed using composer. Find the comand below

composer require abdulnizam/laravel-macros-response-customised

Usage

Custom

To use custom run this comand to config the custom variables

cp 'vendor/abdulnizam/laravel-macros-response-customised/config/laravelmacros.php' config/laravelmacros.php

path : config/laravelmacros.php

custom => array('status', 'message')

custom_error => array('status', 'errors')

then

return response()->custom([1, 'Welcome to the laravel macros']);

Result

{
    "status": 1,
    "message": "Welcome to the laravel macros"
}
return response()->custom_error([0, 'Welcome to the laravel macros']);

Result

{
    "status": 0,
    "errors": "Welcome to the laravel macros"
}

Message

return response()->message('Welcome to laravel macros", 200);

Result

{
    "message": "Welcome to laravel macros"
}

With the Http Status Code: 200

Error

return response()->error('Error message to be displayed', $statuscode = 400);

Result

{
    "message": "Error message to be displayed"
}

With the Http Status Code: 400

Success

return response()->success(['dataname' => 'data'], $statuscode = 200);

Result

{
    "data": {"dataname": "data"}
}

With the Http Status Code: 200

PDF

PDF responses.

return response()->pdf($pdfcontent, 'name.pdf', $download = false);

License

The MIT License (MIT). Please see License File for more information.