{"id":36977662,"url":"https://github.com/imdhemy/jsonable","last_synced_at":"2026-01-13T22:46:53.178Z","repository":{"id":56990337,"uuid":"175718623","full_name":"imdhemy/jsonable","owner":"imdhemy","description":"Laravel JSON response trait.","archived":true,"fork":false,"pushed_at":"2019-09-07T16:05:05.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-22T13:27:50.291Z","etag":null,"topics":["json","json-api","laravel","laravel-package","response"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imdhemy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-15T00:08:06.000Z","updated_at":"2023-01-28T04:12:08.000Z","dependencies_parsed_at":"2022-08-21T13:50:25.013Z","dependency_job_id":null,"html_url":"https://github.com/imdhemy/jsonable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/imdhemy/jsonable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdhemy%2Fjsonable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdhemy%2Fjsonable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdhemy%2Fjsonable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdhemy%2Fjsonable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imdhemy","download_url":"https://codeload.github.com/imdhemy/jsonable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imdhemy%2Fjsonable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403707,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["json","json-api","laravel","laravel-package","response"],"created_at":"2026-01-13T22:46:53.062Z","updated_at":"2026-01-13T22:46:53.167Z","avatar_url":"https://github.com/imdhemy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jsonable\nLaravel JSON response trait. This trait makes it easy for any controller to return a JSON response with the appropriate HTTP status code.\n\n## Installation\nVia composer:\n\n```\ncomposer require imdhemy/jsonable\n```\n\n# Usage\nAll that you need is to `use` the `Jsonable` trait inside your controller.\n\n**Example:**\n\n```php\n\u003c?php\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse Imdhemy\\Jsonable\\Jsonable;\n\nclass CountryController extends Controller\n{\n    use Jsonable;\n\n    public function index()\n    {\n        $data = \\App\\Country::get();\n        return $this-\u003eok($data, 'countries');\n    }\n}\n```\n\n  The previous code will return a JSON response like the following:\n\n```json\n  {\n    \"countries\": [\n        {\n            \"name\": \"Egypt\",\n            \"capital\": \"Cairo\",\n        },\n           ...\n    ]\n}\n```\n\nThe parent key is optional, you can ommit it:\n\n```php\n$data = \\App\\Country::get();\nreturn $this-\u003eok($data);\n```\nThe response will be like the following:\n\n```json\n[\n {\n  \"name\": \"Egypt\",\n  \"capital\": \"Cairo\",\n  },\n        ...\n]\n```\n\n## Available methods\n\n### Success Methods\n| Method | Status code | Description |\n|---|---|---|\n|ok|200|Successful get, patch (return a JSON object)|\n|created|201|Successful post (return a JSON object)|\n|noContent|204|Successful delete|\n\n### Error Status\n\n| Method | Status code | Description |\n|---|---|---|\n|unauthorized|401|Not authenticated|\n|invalid|403|Authenticated, but no permissions|\n|notFound|404|Not Found|\n|invalid|422|Validation|\n\n### Extra methods\n\n| Method | Status code | Description |\n|---|---|---|\n|accepted|202|Successful post, delete, path - async|\n|badRequest|400|The request could not be understood by the server due to malformed syntax|\n|paymentRequired|402|Payment required|","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimdhemy%2Fjsonable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimdhemy%2Fjsonable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimdhemy%2Fjsonable/lists"}