onexcrm / response-structure
Create useful api or service response structure easily.
v1.0.1
2023-02-21 18:56 UTC
This package is auto-updated.
Last update: 2024-12-21 22:38:34 UTC
README
Create response structure for API call or Service call - easily.
Installation
composer require onexcrm/response-structure
Laravel without auto-discovery:
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
Onex\Responsestructure\OnexResponseStructureServiceProvider::class,
If you want to use the facade to log messages, add this to your facades in app.php:
'OnexResponse'=> Onex\Responsestructure\Responsestructure\ResponseStructureClassFacade::class,
How to use?:
/** * 1st @param array $dataBag * 2nd @param string $responseMessage (default = '') * 3rd @param string $bodyMessageTitle (default = '') * 4th @param string $bodyMessage (default = '') * 5th @param string $messageType (default = 'success') * 6th @param string $responseStatus (default = '200') * 7th @param string $responseType (default = 'success') * 8th @param string $httpCode (default = '200') */
Example #1 (Array Format)
$getResponse = OnexResponse::constructResponse($userData, 'User list found'); dd($getResponse);
Example #2 (Json Format)
$getResponse = OnexResponse::constructResponseJson($userData, 'User list found'); dd($getResponse);
Example #3 (Json Object Response Format)
$getResponse = OnexResponse::constructResponseJsonObject($userData, 'User list found'); dd($getResponse);
Sample Response
Feel free to contact me: Arindam Roy arindam.roy.developer@gmail.com