{"id":20531945,"url":"https://github.com/aidynmakhataev/laravel-filterable","last_synced_at":"2026-04-18T19:32:28.977Z","repository":{"id":56942672,"uuid":"139683973","full_name":"AidynMakhataev/laravel-filterable","owner":"AidynMakhataev","description":"A laravel package to handle filtering by URL query string","archived":false,"fork":false,"pushed_at":"2018-07-13T08:11:25.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-01T13:11:13.595Z","etag":null,"topics":["filterable","filtering","laravel","laravel-5-package","laravel-filter","php","query-filter"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AidynMakhataev.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}},"created_at":"2018-07-04T07:19:29.000Z","updated_at":"2018-11-24T11:48:05.000Z","dependencies_parsed_at":"2022-08-21T07:50:34.448Z","dependency_job_id":null,"html_url":"https://github.com/AidynMakhataev/laravel-filterable","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/AidynMakhataev/laravel-filterable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidynMakhataev%2Flaravel-filterable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidynMakhataev%2Flaravel-filterable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidynMakhataev%2Flaravel-filterable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidynMakhataev%2Flaravel-filterable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AidynMakhataev","download_url":"https://codeload.github.com/AidynMakhataev/laravel-filterable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AidynMakhataev%2Flaravel-filterable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278444495,"owners_count":25987788,"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-10-05T02:00:06.059Z","response_time":54,"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":["filterable","filtering","laravel","laravel-5-package","laravel-filter","php","query-filter"],"created_at":"2024-11-16T00:11:09.551Z","updated_at":"2025-10-05T10:40:40.320Z","avatar_url":"https://github.com/AidynMakhataev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LaravelFilterable\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![Build Status][ico-travis]][link-travis]\n[![StyleCI][ico-styleci]][link-styleci]\n\nA laravel package to handle filtering by URL query strings\n\n## Installation\n\nVia Composer\n\n``` bash\n$ composer require aidynmakhataev/laravel-filterable\n```\n\n## Usage\n1. Create a new filter with the following artisan command: \n\n```bash\nphp artisan make:filter UserFilter\n```\n\nThis will create ```App\\Http\\Filters\\UserFilter.php```. You can override the default namespace in **```config/filterable.php```** \u003cbr\u003e\n\n```php\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Filters Configuration\n    |--------------------------------------------------------------------------\n    |\n    */\n\n    // namespace for the generated filters\n    'namespace' =\u003e  'App\\Http\\Filters'\n];\n```\nThen, you need to define your filter logic by following this rules:\n- Query string without a corresponding filter method are ignored\n- Empty strings are ignored\n- The value of the each request keys are injected into the corresponding filter method\n- You are able to access the eloquent query builder instance by using ```$this-\u003ebuilder```\n\n**Example**: \u003cbr\u003e\n\nFor defining methods for the following url request:\n\n``` http://yourdomain.com/api/users?gender=male\u0026working=1  ```\n\n\u003cbr\u003e\n\nYou would use the following methods:\n\n\n```php\nnamespace App\\Http\\Filters;\n\nuse AidynMakhataev\\LaravelFilterable\\BaseFilter;\n\nclass UserFilter extends BaseFilter\n{\n    public function gender($value)\n    {\n        return $this-\u003ebuilder-\u003ewhere('gender', $value);\n    }\n\n    public function working($value)\n    {\n        return $this-\u003ebuilder-\u003ewhere('is_working', $value);\n    }\n}\n```\n\n\n2. Add the trait and bind created in step 1 Filter Class to your model.\n\n ```php\nuse AidynMakhataev\\LaravelFilterable\\Filterable;\n\nclass User extends Authenticatable\n{\n    use Filterable;\n\n    /**\n     * Filters attribute.\n     *\n     * @var array\n     */\n    protected $filters = \\App\\Http\\Filters\\UserFilter::class;\n\n}\n```\n\n3. Finally, use it in your Controller:\n```php\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse App\\User;\n\nclass UserController extends Controller\n{\n    public function index(Request $request)\n    {\n        $users = User::filter($request-\u003eall())-\u003eget();\n\n        return response()-\u003ejson($users);\n    }\n}\n```\n\n## Contributing\n\nAnyone is welcome to contribute. Fork, make your changes, and then submit a pull request.\n\n## Security\n\nIf you discover any security related issues, please email makataev.7@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Aidyn Makhataev][link-author] \n\n## License\n\nMIT. Please see the [license file](license.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/aidynmakhataev/laravelfilterable.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/aidynmakhataev/laravelfilterable.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/aidynmakhataev/laravelfilterable/master.svg?style=flat-square\n[ico-styleci]: https://github.styleci.io/repos/139683973/shield\n\n[link-packagist]: https://packagist.org/packages/aidynmakhataev/laravel-filterable\n[link-downloads]: https://packagist.org/packages/aidynmakhataev/laravel-filterable\n[link-travis]: https://travis-ci.org/aidynmakhataev/laravelfilterable\n[link-styleci]: https://github.styleci.io/repos/139683973\n[link-author]: https://github.com/AidynMakhataev\n[link-contributors]: ../../contributors]","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidynmakhataev%2Flaravel-filterable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faidynmakhataev%2Flaravel-filterable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faidynmakhataev%2Flaravel-filterable/lists"}