abdulnizam/laravel-macros-response-customised

Customised Response Macro's for Laravel

v3.2 2018-01-28 08:03 UTC

This package is auto-updated.

Last update: 2025-06-20 23:01:14 UTC


README

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.