{"id":42183025,"url":"https://github.com/ralphmorris/laravel-query-filter","last_synced_at":"2026-01-26T22:14:41.779Z","repository":{"id":143728573,"uuid":"170943113","full_name":"ralphmorris/laravel-query-filter","owner":"ralphmorris","description":"Easily add dedicated query filters based on request parameters.","archived":false,"fork":false,"pushed_at":"2019-12-03T23:11:45.000Z","size":17,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-11T15:27:51.199Z","etag":null,"topics":["filter","laravel","laravel-5-package","queryfilter"],"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/ralphmorris.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":"2019-02-15T23:48:23.000Z","updated_at":"2022-08-12T08:39:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"e2209470-cb91-4ff3-80d2-34b715024c8b","html_url":"https://github.com/ralphmorris/laravel-query-filter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ralphmorris/laravel-query-filter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphmorris%2Flaravel-query-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphmorris%2Flaravel-query-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphmorris%2Flaravel-query-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphmorris%2Flaravel-query-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralphmorris","download_url":"https://codeload.github.com/ralphmorris/laravel-query-filter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralphmorris%2Flaravel-query-filter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28789723,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T21:49:50.245Z","status":"ssl_error","status_checked_at":"2026-01-26T21:48:29.455Z","response_time":59,"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":["filter","laravel","laravel-5-package","queryfilter"],"created_at":"2026-01-26T22:14:41.049Z","updated_at":"2026-01-26T22:14:41.773Z","avatar_url":"https://github.com/ralphmorris.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Query Filter\n\n\u003c!-- [![Latest Version on Packagist](https://img.shields.io/packagist/v/ralphmorris/laravel-query-filter.svg?style=flat-square)](https://packagist.org/packages/ralphmorris/laravel-query-filter) --\u003e\n\u003c!-- [![Build Status](https://img.shields.io/travis/ralphmorris/laravel-query-filter/master.svg?style=flat-square)](https://travis-ci.org/ralphmorris/laravel-query-filter) --\u003e\n\u003c!-- [![Quality Score](https://img.shields.io/scrutinizer/g/ralphmorris/laravel-query-filter.svg?style=flat-square)](https://scrutinizer-ci.com/g/ralphmorris/laravel-query-filter) --\u003e\n\u003c!-- [![Total Downloads](https://img.shields.io/packagist/dt/ralphmorris/laravel-query-filter.svg?style=flat-square)](https://packagist.org/packages/ralphmorris/laravel-query-filter) --\u003e\n\nEasily add dedicated filters based on request parameters. Originally came from a great tutorial on Laracasts. After copying it from project to project a few times I've now put it into a little package and added a generator for ease of use.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require ralphmorris/laravel-query-filter\n```\n\n## Usage\n\nTo allow a model to be filterable, first add the FilterableTrait to your model.\n\n``` php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse RalphMorris\\LaravelQueryFilter\\FilterableTrait;\n\nclass Post extends Model\n{\n    use FilterableTrait;\n}\n```\n\nThen to create your filter class run the command below.\n\n```bash\nphp artisan make:filter PostFilters\n```\n\nThis will place the filter class under an App\\Filters namespace if you are using the default namespace/directory structure. It should look like this.\n\n```php\nnamespace App\\Filters;\n\nuse RalphMorris\\LaravelQueryFilter\\QueryFilter;\n\nclass PostFilters extends QueryFilter\n{\n    /**\n     * Example\n     * \n     * The request parameter key as the method name.\n     * Passes the parameters value to the method \n     * so we can apply a filter to the query.\n     * \n     * @param  mixed $param Value of the request parameter\n     */\n    public function example_request_param($param)\n    {\n        $this-\u003ebuilder-\u003ewhere('example_request_param', $param);\n    }\n}\n```\n\nIf you wanted to add a filter on the title and author ID, you might do something like this.\n\n```php\nnamespace App\\Filters;\n\nuse RalphMorris\\LaravelQueryFilter\\QueryFilter;\n\nclass PostFilters extends QueryFilter\n{\n    public function title($title)\n    {\n        $this-\u003ebuilder-\u003ewhere('title', 'like', \"%{$title}%\");\n    }\n\n    public function author($authorId)\n    {\n        $this-\u003ebuilder-\u003ewhere('author_id', $authorId);\n    }\n}\n```\n\nFinally to add the filters to your query apply filter() query scope in the FilterableTrait to your query and pass the PostFilters class through. \n\n```php\npublic function index(PostFilters $filters)\n{\n    $posts = Post::filter($filters)-\u003eget();\n}\n```\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### Security\n\nIf you discover any security related issues, please email ralph@bubblehubsolutions.co.uk instead of using the issue tracker.\n\n## Credits\n\n- [Ralph Morris](https://github.com/ralphmorris)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n## Laravel Package Boilerplate\n\nThis package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphmorris%2Flaravel-query-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralphmorris%2Flaravel-query-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralphmorris%2Flaravel-query-filter/lists"}