{"id":15106876,"url":"https://github.com/vskut/laravel-api-resource-filterable","last_synced_at":"2025-09-02T11:41:49.038Z","repository":{"id":62545588,"uuid":"192182961","full_name":"VSKut/laravel-api-resource-filterable","owner":"VSKut","description":"Filterable methods (only/except) for laravel Api Resources (eloquent-resources)","archived":false,"fork":false,"pushed_at":"2019-06-16T11:47:13.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-05T13:30:16.426Z","etag":null,"topics":["api-resources","eloquent-resources","filterable","laravel","laravel-framework","laravel5","php","php7"],"latest_commit_sha":null,"homepage":"","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/VSKut.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":"2019-06-16T11:26:21.000Z","updated_at":"2019-06-16T11:49:48.000Z","dependencies_parsed_at":"2022-11-02T22:01:25.087Z","dependency_job_id":null,"html_url":"https://github.com/VSKut/laravel-api-resource-filterable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VSKut/laravel-api-resource-filterable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VSKut%2Flaravel-api-resource-filterable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VSKut%2Flaravel-api-resource-filterable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VSKut%2Flaravel-api-resource-filterable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VSKut%2Flaravel-api-resource-filterable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VSKut","download_url":"https://codeload.github.com/VSKut/laravel-api-resource-filterable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VSKut%2Flaravel-api-resource-filterable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273279615,"owners_count":25077317,"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-09-02T02:00:09.530Z","response_time":77,"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-resources","eloquent-resources","filterable","laravel","laravel-framework","laravel5","php","php7"],"created_at":"2024-09-25T21:02:29.564Z","updated_at":"2025-09-02T11:41:49.014Z","avatar_url":"https://github.com/VSKut.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Api Resource filterable\n\nProvides the filtering trait for Laravel 5 Api Resources.\n\n## Install\n\nVia composer:\n\n`$ composer require vskut/laravel-api-resource-filterable`\n\n## Usage\n### Resource\n```php\nnamespace App\\Http\\Resources;\n\nuse vskut\\laravel-api-resource-filterable\\Filterable;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass UserResource extends JsonResource\n{\n    use Filtratable;\n\n    public function toArray($request)\n    {\n        return $this-\u003efiltrateFields([\n            'id' =\u003e $this-\u003eid,\n            'name' =\u003e $this-\u003ename,\n            'email' =\u003e $this-\u003eemail,\n        ]);\n    }\n}\n```\n\n### Collection\n```php\nnamespace App\\Http\\Resources;\n\nuse vskut\\laravel-api-resource-filterable\\Filterable;\nuse Illuminate\\Http\\Resources\\Json\\ResourceCollection;\n\nclass UserResourceCollection extends ResourceCollection\n{\n    use Filtratable;\n\n    public function toArray($request)\n    {\n        return [\n            'data' =\u003e $this-\u003eprocessCollection($request),\n        ];\n    }\n}\n```\n\n### Controller\n```php\nnamespace App\\Http\\Controllers;\n\nuse App\\Http\\Controllers\\Controller;\nuse App\\Http\\Resources\\UserResource;\nuse App\\User;\n\nclass UserController extends Controller\n{\n\n    public function index()\n    {\n        $users = User::all();\n    \n        return UserCollection::make($users)-\u003eonly(['id', 'name', 'email']);\n        //return UserCollection::make($users)-\u003eexcept(['email']);\n    }\n\n    public function show(User $user)\n    {\n        return UserResource::make($user)-\u003eonly(['id', 'name', 'email']);\n        // return UserResource::make($user)-\u003eexcept(['email']);\n    }\n}\n```\n\n\n## Credits\n\n* [Markus Lind](https://github.com/vskut)\n* [All Contributors](https://github.com/vskut/laravel-api-resource-filterable/contributors)\n\n## License\n\nThe MIT License (MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvskut%2Flaravel-api-resource-filterable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvskut%2Flaravel-api-resource-filterable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvskut%2Flaravel-api-resource-filterable/lists"}