{"id":33985563,"url":"https://github.com/djurovicigoor/lara-json-response","last_synced_at":"2025-12-13T04:57:24.065Z","repository":{"id":56969893,"uuid":"147670492","full_name":"djurovicigoor/lara-json-response","owner":"djurovicigoor","description":"Laravel API wrapper for returning JSON response.","archived":false,"fork":false,"pushed_at":"2020-09-14T14:59:35.000Z","size":27,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-10T23:43:53.437Z","etag":null,"topics":["api","json","laravel","response"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/djurovicigoor.png","metadata":{"files":{"readme":"readme.md","changelog":"changelog.md","contributing":"contributing.md","funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-06T12:30:51.000Z","updated_at":"2023-08-08T11:12:51.000Z","dependencies_parsed_at":"2022-08-21T10:50:43.334Z","dependency_job_id":null,"html_url":"https://github.com/djurovicigoor/lara-json-response","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/djurovicigoor/lara-json-response","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djurovicigoor%2Flara-json-response","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djurovicigoor%2Flara-json-response/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djurovicigoor%2Flara-json-response/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djurovicigoor%2Flara-json-response/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/djurovicigoor","download_url":"https://codeload.github.com/djurovicigoor/lara-json-response/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/djurovicigoor%2Flara-json-response/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27700396,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","json","laravel","response"],"created_at":"2025-12-13T04:57:23.588Z","updated_at":"2025-12-13T04:57:24.057Z","avatar_url":"https://github.com/djurovicigoor.png","language":"PHP","funding_links":["https://paypal.me/djurovicigoor?locale.x=en_US"],"categories":[],"sub_categories":[],"readme":"# LaraJsonResponse\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/djurovicigoor/larajsonresponse.svg?style=for-the-badge)](https://packagist.org/packages/djurovicigoor/larajsonresponse)\n![Total Downloads](https://img.shields.io/packagist/dt/djurovicigoor/larajsonresponse.svg?style=for-the-badge)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)\n![Scrutinizer code quality (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/quality/g/djurovicigoor/lara-json-response/master.svg?style=for-the-badge)\n![Scrutinizer build (GitHub/Bitbucket)](https://img.shields.io/scrutinizer/build/g/djurovicigoor/lara-json-response/master.svg?style=for-the-badge)\n\nLaravel API wrapper for returning JSON response.\n\n## Installation\n\nVia Composer\n\n``` bash\n$ composer require djurovicigoor/larajsonresponse\n```\n\n## Usage\n\nThe base method is **laraResponse()**;\n``` bash\n    return laraResponse();\n```\nJSON response of this method will be:\n``` bash\n{\n    \"code\": 200,\n    \"message\": null,\n    \"data\": null,\n    \"error\": null\n}\n```\nIf you want to return success JSON response with data and status code 200, you have to use **laraResponse($message , $data)-\u003esuccess()**\n``` bash\n    $data = ['name' =\u003e 'John Doe', 'location' =\u003e 'unknown' , 'age' =\u003e 24];\n\t\n    return laraResponse(\"My message.\" , $data)-\u003esuccess();\n```\nJSON response of this method will be:\n``` bash\n{\n    \"code\": 200,\n    \"message\": \"My message.\",\n    \"data\": {\n        \"name\": \"John Doe\",\n        \"location\": \"unknown\",\n        \"age\": 24\n    },\n    \"error\": null\n}\n```\nIf you want to return error JSON response with message, ERROR and status code 400, you have to use **laraResponse($message , NULL , $error)-\u003eerror()**\n``` bash\n    return laraResponse('My message.' , NULL , \"TYPE_OF_ERROR\")-\u003eerror();\n```\nJSON response of this method will be:\n``` bash\n{\n    \"code\": 400,\n    \"message\": \"My message.\",\n    \"data\": null,\n    \"error\": \"TYPE_OF_ERROR\"\n}\n```\nIf you want to return unauthorized JSON response response with 401 status code, you have to use **laraResponse($message)-\u003eunAuthorized()**\n``` bash\n    return laraResponse('This action is unauthorized.')-\u003eunAuthorized();\n```\nJSON response of this method will be:\n``` bash\n{\n    \"code\": 401,\n    \"message\": \"This action is unauthorized.\",\n    \"data\": null,\n    \"error\": null\n}\n```\nIf you want to return forbidden JSON response response with 403 status code, you have to use **laraResponse($message)-\u003eforbidden()**\n``` bash\n    return laraResponse('Forbidden!')-\u003eforbidden();\n```\nJSON response of this method will be:\n``` bash\n{\n    \"code\": 403,\n    \"message\": \"Forbidden!\",\n    \"data\": null,\n    \"error\": null\n}\n```\nIf you want to return not found JSON response with 404 status code , you have to use **laraResponse($message)-\u003enotFound()**\n``` bash\n    return laraResponse('Not Found!')-\u003enotFound();\n```\nJSON response of this method will be:\n``` bash\n{\n    \"code\": 404,\n    \"message\": \"Not Found!\",\n    \"data\": null,\n    \"error\": null\n}\n```\nAnd finaly you can use **laraResponse($message)-\u003ecustomCode($yourCustomCode)** to return JSON response with yout custom code;\n``` bash\nreturn laraResponse('My custom status code!')-\u003ecustomCode($yourCustomCode);\n```\nJSON response of this method will be:\n``` bash\n{\n    \"code\": $yourCustomCode,\n    \"message\": \"My custom status code!\",\n    \"data\": null,\n    \"error\": null\n}\n```\n\n## Change log\n\nPlease see the [changelog](changelog.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [contributing.md](contributing.md) for details and a todolist.\n\n## Security\n\nIf you discover any security related issues, please email djurovic.igoor@gmail.com instead of using the issue tracker.\n\n## Donate\n\nIf you found this project helpful or you learned something from the source code and want to appreciate\n\n- [PayPal](https://paypal.me/djurovicigoor?locale.x=en_US)\n\n## Credits\n\n- [Djurovic Igor][link-author]\n\n## License\n\nMIT. Please see the [license file](license.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/djurovicigoor/larajsonresponse.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/djurovicigoor/larajsonresponse.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/djurovicigoor/larajsonresponse/master.svg?style=flat-square\n[ico-styleci]: https://styleci.io/repos/12345678/shield\n\n[link-packagist]: https://packagist.org/packages/djurovicigoor/larajsonresponse\n[link-downloads]: https://packagist.org/packages/djurovicigoor/larajsonresponse\n[link-travis]: https://travis-ci.org/djurovicigoor/larajsonresponse\n[link-styleci]: https://styleci.io/repos/12345678\n[link-author]: https://github.com/djurovicigoor\n[link-contributors]: ../../contributors]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjurovicigoor%2Flara-json-response","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdjurovicigoor%2Flara-json-response","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdjurovicigoor%2Flara-json-response/lists"}