{"id":21207275,"url":"https://github.com/jeidison/model-filtrable","last_synced_at":"2026-04-28T00:33:32.694Z","repository":{"id":56997829,"uuid":"246145625","full_name":"jeidison/model-filtrable","owner":"jeidison","description":"Filter Eloquent Models and Relationships","archived":false,"fork":false,"pushed_at":"2021-01-08T02:32:05.000Z","size":42,"stargazers_count":0,"open_issues_count":6,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-09T21:45:23.216Z","etag":null,"topics":["eloquent","filter","filtrable","laravel","like","model","query","relationship","search","sort","with"],"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/jeidison.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":"2020-03-09T21:27:35.000Z","updated_at":"2022-09-19T17:30:03.000Z","dependencies_parsed_at":"2022-08-21T14:10:46.228Z","dependency_job_id":null,"html_url":"https://github.com/jeidison/model-filtrable","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/jeidison/model-filtrable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeidison%2Fmodel-filtrable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeidison%2Fmodel-filtrable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeidison%2Fmodel-filtrable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeidison%2Fmodel-filtrable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeidison","download_url":"https://codeload.github.com/jeidison/model-filtrable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeidison%2Fmodel-filtrable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32361477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["eloquent","filter","filtrable","laravel","like","model","query","relationship","search","sort","with"],"created_at":"2024-11-20T20:58:16.933Z","updated_at":"2026-04-28T00:33:32.677Z","avatar_url":"https://github.com/jeidison.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Model Filtrable\n\n### Installation\n\n```bash\n$ composer require jeidison/model-filtrable\n```\n# Usage\n\n#### Add Trait in model\n\n\n```php\n...\n\nuse Jeidison\\Filtrable\\Filtrable;\n\nclass Professional extends Model\n{\n    use Filtrable;\n\n    ...\n    protected $fillable = [\n        //All fields filtrable;\n    ];\n    ...\n\n    public function places()\n    {\n        return $this-\u003ebelongsToMany(Place::class, 'prof_place', 'id_prof', 'id_place');\n    }\n    \n    public function specialties()\n    {\n        return $this-\u003ebelongsToMany(Specialty::class, 'prof_spec', 'id_prof', 'id_spec');\n    }\n}\n```\n\n#### Service\n\n```php\n...\n\nuse App\\Models\\Professional;\n\nclass ProfessionalService implements IProfessionalService\n{\n    public function filter()\n    {\n         return Professional::filter(request()-\u003eall())-\u003eget(); \n        // or\n         return Professional::filter(['field_one' =\u003e 'value1'])-\u003eget();     \n    }\n}\n```\n\n## Querying at the API-endpoint\n\n### Filtering:\n\nWhere\n```\n    /api/professionals?id_prof=1\n    or\n    /api/professionals?id_prof:==1\n    or\n    /api/professionals?id_prof:\u003c\u003e=1\n    or\n    /api/professionals?id_prof:!==1\n    or\n    /api/professionals?id_prof:\u003e=1\n    or\n    /api/professionals?id_prof:\u003c=1\n    ...\n```\n\nWhereIn\n```\n    /api/professionals?id_prof:in=1,2\n```\n\nWhereNotIn\n```\n    /api/professionals?id_prof:notIn=1,2\n```\n\nWhereBetween\n```\n    /api/professionals?id_prof:between=1,2\n    /api/professionals?updated_at:between=2020-03-10 14:00:27,2020-03-10 14:00:27\n```\n\nWhereNotBetween\n```\n    /api/professionals?id_prof:notBetween=1,2\n    /api/professionals?updated_at:notBetween=2020-03-10 14:00:27,2020-03-10 14:00:27\n```\n\nWhereNull\n```\n    /api/professionals?id_prof:null=\n```\n\nWhereNotNull\n```\n    /api/professionals?id_prof:notNull=\n```\n\nWhere Like\n```\n    /api/professionals?prof_name:like=Jeidison%\n```\n\nWhere Date\n```\n    /api/professionals?created_at:whereDate=2020-03-10\n```\n\norWhere\n```\n    /api/professionals?id_prof:\u003e=100\u0026prof_name:orWhere=Jeidison\n```\n\nWith:\n```\n    /api/professionals?with=places,specialties\n```\n\nHas:\n```\n    /api/professionals?has=places\n```\n\nRelationship:\n```\n    /api/places-\u003eid_place=1\n    /api/places-\u003eprofessionals-\u003eid_place=1\n    /api/places-\u003eprofessionals-\u003eid_place:\u003c\u003e=1\n    /api/places-\u003eprofessionals-\u003eid_place:\u003c=1\n    ...\n```\n\nOrder By:\n```\n    /api/professionals?order=id_place\n    or \n    /api/professionals?order=id_prof:desc\n    or \n    /api/professionals?order=id_prof:asc\n    or \n    /api/professionals?order=id_place,id_prof:desc\n    or \n    /api/professionals?order=id_place:asc,id_prof:desc\n```\n\nFields Response:\n```\n    /api/professionals?fields=id_place,prof_name,prof_phone,prof_email\n```\n\nPaginate:\n```\n    /api/professionals?paginate\n    or\n    /api/professionals?paginate\u0026paginate:page=0\n    or\n    /api/professionals?paginate\u0026paginate:perPage=10\u0026paginate:page=0\n    ...\n```\n\n## Credits\n- [Jeidison Farias](https://github.com/jeidison)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeidison%2Fmodel-filtrable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeidison%2Fmodel-filtrable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeidison%2Fmodel-filtrable/lists"}