{"id":15296440,"url":"https://github.com/samaviam/model-filtration","last_synced_at":"2026-05-18T00:32:54.986Z","repository":{"id":65588730,"uuid":"595236069","full_name":"samaviam/model-filtration","owner":"samaviam","description":"Filtering the desired model records using query string in Laravel app","archived":false,"fork":false,"pushed_at":"2023-02-06T18:08:35.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-12T08:41:52.028Z","etag":null,"topics":["laravel","laravel-package","php","php-attributes","php8"],"latest_commit_sha":null,"homepage":"","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/samaviam.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T17:14:40.000Z","updated_at":"2023-01-30T19:27:43.000Z","dependencies_parsed_at":"2023-02-16T10:31:19.510Z","dependency_job_id":null,"html_url":"https://github.com/samaviam/model-filtration","commit_stats":null,"previous_names":["samaviam/model-filtration"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/samaviam/model-filtration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samaviam%2Fmodel-filtration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samaviam%2Fmodel-filtration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samaviam%2Fmodel-filtration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samaviam%2Fmodel-filtration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samaviam","download_url":"https://codeload.github.com/samaviam/model-filtration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samaviam%2Fmodel-filtration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33160481,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"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":["laravel","laravel-package","php","php-attributes","php8"],"created_at":"2024-09-30T18:10:30.148Z","updated_at":"2026-05-18T00:32:54.966Z","avatar_url":"https://github.com/samaviam.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Filtering the desired model records using query string in Laravel app\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/samavidev/model-filtration.svg?style=flat-square)](https://packagist.org/packages/samavidev/model-filtration)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/samavidev/model-filtration/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/samavidev/model-filtration/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/samavidev/model-filtration/fix-php-code-style-issues.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/samavidev/model-filtration/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/samavidev/model-filtration.svg?style=flat-square)](https://packagist.org/packages/samavidev/model-filtration)\n\nThis package provides an annotation to retrieve records of a specific model filtered using a query string. Here's a quick example:\n\n```php\nnamespace App\\Models;\n\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\nuse SamaviDev\\ModelFiltration\\Attributes\\Filter;\n\n#[Filter(['name' =\u003e 'username'])]\nclass User extends Authenticatable\n{\n    ...\n}\n```\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require samavidev/model-filtration\n```\n\n## Usage\n\n- The first argument is valid fields that can be used in the query string. which can be in the form of a string or an array, you can also use an association array to assign a query to a specific model.\n- The second argument is the operator that is applied to the table fields (`and`, `or`, `like`, `like:or`). You can even use `with` for relationships. The default value is `and`.\n\nfor example:\n```php\n#[Filter(['name' =\u003e 'username', 'email' =\u003e 'useremail'], 'or')]\n```\n\nIt can also be used multiple times.\n```php\nnamespace App\\Models;\n\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\nuse SamaviDev\\ModelFiltration\\Attributes\\Filter;\n\n#[Filter('id')]\n#[Filter(['name' =\u003e 'username'])]\nclass User extends Authenticatable\n{\n    ...\n}\n```\n\n##### Filter group definition:\nYou can also define an `Attribute` class to use as a group of filters for your models. For this, you must implement the `Group` interface.\n```php\nnamespace App\\Attributes;\n\nuse Attribute;\nuse SamaviDev\\ModelFiltration\\Contracts\\Group;\n\n#[Attribute]\nclass UsersFilter implements Group\n{\n    public function props(): array\n    {\n        return [\n            'or' =\u003e ['attribute', ...]\n            'and' =\u003e ['attribute' =\u003e 'alias', ...],\n            ...\n        ];\n    }\n}\n```\nAnd finally, you can use it in your model like this:\n```php\nnamespace App\\Models;\n\nuse Illuminate\\Foundation\\Auth\\User as Authenticatable;\nuse App\\Attributes\\UsersFilter;\n\n#[UsersFilter]\nclass User extends Authenticatable\n{\n    ...\n}\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Mahdi Samavi](https://github.com/SamaviDev)\n- [All Contributors](../../contributors)\n\n## License\n\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%2Fsamaviam%2Fmodel-filtration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamaviam%2Fmodel-filtration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamaviam%2Fmodel-filtration/lists"}