{"id":18212001,"url":"https://github.com/bedus-creation/l9-repository","last_synced_at":"2025-04-07T20:44:44.860Z","repository":{"id":63070516,"uuid":"432938049","full_name":"bedus-creation/l9-repository","owner":"bedus-creation","description":null,"archived":false,"fork":false,"pushed_at":"2023-08-26T14:49:00.000Z","size":49,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T22:26:05.029Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bedus-creation.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-11-29T07:04:47.000Z","updated_at":"2022-06-06T15:42:32.000Z","dependencies_parsed_at":"2023-02-12T16:10:10.969Z","dependency_job_id":null,"html_url":"https://github.com/bedus-creation/l9-repository","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bedus-creation%2Fl9-repository","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bedus-creation%2Fl9-repository/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bedus-creation%2Fl9-repository/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bedus-creation%2Fl9-repository/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bedus-creation","download_url":"https://codeload.github.com/bedus-creation/l9-repository/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247729345,"owners_count":20986392,"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-03T15:04:21.662Z","updated_at":"2025-04-07T20:44:44.589Z","avatar_url":"https://github.com/bedus-creation.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel L9-Repository\nA basic data lever wrapper for Laravel's Eloquent model with the features such as Transformers, Filters, Caching etc.\n\n### Installation\n```bash\ncomposer require aammui/l9-repository\n```\n\n### Uses\n* [Transformers](https://github.com/bedus-creation/l9-repository#transformers)\n\n### Transformers\nFirst define a `UserTransformer`\n```php\nclass UserTransformer extends TransformerAbstract\n{\n    public function transform(User $user)\n    {\n        return [\n            'id' =\u003e $user-\u003eid,\n            'name' =\u003e $user-\u003ename\n        ];\n    }\n}\n```\nand use it as,\n\n```php\napp()-\u003emake(UserRepository::class)\n    -\u003esetTransformer(UserTransformer::class)\n    -\u003eget();\n```\n\nOr use with custom includes,\n```php\napp()-\u003emake(UserRepository::class)\n    -\u003esetTransformer(UserTransformer::class, function(\\League\\Fractal\\Manager $manager){\n        $manager-\u003eparseIncludes('role');\n    })\n    -\u003eget();\n```\nand add `role` to `availableIncludes` in `UserTransformer`\n```php\nprotected array $availableIncludes = [\n    'role'\n];\n\npublic function transform(User $user){...}\n\npublic function includeRole(User $user): Item\n{\n    $author = $user-\u003erole;\n\n    return $this-\u003eitem($author, new class extends TransformerAbstract {\n        public function transform(Role $role): array\n        {\n            return [\n                'id'    =\u003e $role-\u003eid,\n                'label' =\u003e $role-\u003elabel,\n            ];\n        }\n    });\n}\n```\n\n## Credits\n- [Bedram Tamang](https://github.com/bedus-creation/)\n- [All Contributors](../../contributors)\n\n## License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbedus-creation%2Fl9-repository","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbedus-creation%2Fl9-repository","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbedus-creation%2Fl9-repository/lists"}