{"id":21404708,"url":"https://github.com/eightyfive/laravel-normalizr","last_synced_at":"2026-01-02T17:48:32.594Z","repository":{"id":56980750,"uuid":"259515358","full_name":"eightyfive/laravel-normalizr","owner":"eightyfive","description":"Normalizr Laravel Eloquent API Resources","archived":false,"fork":false,"pushed_at":"2020-06-19T11:33:53.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-23T03:41:23.309Z","etag":null,"topics":[],"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/eightyfive.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":"2020-04-28T02:56:33.000Z","updated_at":"2020-06-19T11:33:55.000Z","dependencies_parsed_at":"2022-08-21T08:40:51.084Z","dependency_job_id":null,"html_url":"https://github.com/eightyfive/laravel-normalizr","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eightyfive%2Flaravel-normalizr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eightyfive%2Flaravel-normalizr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eightyfive%2Flaravel-normalizr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eightyfive%2Flaravel-normalizr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eightyfive","download_url":"https://codeload.github.com/eightyfive/laravel-normalizr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243902291,"owners_count":20366259,"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","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":[],"created_at":"2024-11-22T16:17:40.207Z","updated_at":"2026-01-02T17:48:32.567Z","avatar_url":"https://github.com/eightyfive.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laravel-normalizr\nNormalizr Laravel Eloquent API Resources\n\n## Install\n\n```\ncomposer require eyf/laravel-normalizr\n```\n\n## Usage\n\n```php\nuse Eyf\\Normalizr\\Http\\Resources\\JsonResource;\n\nclass User extends JsonResource\n{\n  public function toArray($request)\n  {  \n    return [\n      'id' =\u003e $this-\u003eid,\n      'name' =\u003e $this-\u003ename,\n      // ...\n\n      'posts' =\u003e Post::collection($this-\u003ewhenLoaded('posts')),\n    ];\n  }\n}\n```\n\n### Controller\n\nAssuming [route model binding](https://laravel.com/docs/7.x/routing#route-model-binding).\n\n```php\nuse App\\Http\\Resources\\User as UserResource;\n\nclass UserController extends Controller\n{\n  public function find(Request $request, User $user)\n  {\n    $user-\u003eloadMissing('posts');\n    \n    return new UserResource($user);\n  }\n}\n```\n\n### Response\n\n```json\n{\n  \"data\": {\n    \"entities\": {\n      \"users\": {\n        \"1\": {\n          \"id\": 1,\n          \"name\": \"John\",\n          \"posts\": [2, 3]\n        }\n      },\n      \"posts\": {\n        \"2\": {\n          \"id\": 2,\n          \"title\": \"Post 2\"\n        },\n        \"3\": {\n          \"id\": 3,\n          \"title\": \"Post 3\"\n        }\n      }\n    },\n    \"result\": 1\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feightyfive%2Flaravel-normalizr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feightyfive%2Flaravel-normalizr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feightyfive%2Flaravel-normalizr/lists"}