{"id":23219104,"url":"https://github.com/b2pweb/bdf-form-filter-prime","last_synced_at":"2026-02-09T17:31:21.249Z","repository":{"id":41310237,"uuid":"330663695","full_name":"b2pweb/bdf-form-filter-prime","owner":"b2pweb","description":"Helper library for BDF Form to create Prime filters","archived":false,"fork":false,"pushed_at":"2024-12-03T15:15:13.000Z","size":91,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-23T01:51:50.998Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/b2pweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2021-01-18T12:46:14.000Z","updated_at":"2024-10-11T07:55:48.000Z","dependencies_parsed_at":"2024-03-05T14:55:52.220Z","dependency_job_id":"046c655a-fc63-479c-9d64-e27b2060b28e","html_url":"https://github.com/b2pweb/bdf-form-filter-prime","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"38fb7002484966194c3136a361cbbeab6a35bf33"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/b2pweb/bdf-form-filter-prime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-filter-prime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-filter-prime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-filter-prime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-filter-prime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b2pweb","download_url":"https://codeload.github.com/b2pweb/bdf-form-filter-prime/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-form-filter-prime/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266681598,"owners_count":23967804,"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-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"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":[],"created_at":"2024-12-18T21:19:18.242Z","updated_at":"2026-02-09T17:31:16.208Z","avatar_url":"https://github.com/b2pweb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Form filter for Prime\n\nHelper library for BDF Form to create Prime filters.\n\n[![build](https://github.com/b2pweb/bdf-form-filter-prime/actions/workflows/php.yml/badge.svg)](https://github.com/b2pweb/bdf-form-filter-prime/actions/workflows/php.yml)\n[![codecov](https://codecov.io/github/b2pweb/bdf-form-filter-prime/branch/master/graph/badge.svg?token=VOFSPEWYKX)](https://app.codecov.io/github/b2pweb/bdf-form-filter-prime)\n[![Packagist Version](https://img.shields.io/packagist/v/b2pweb/bdf-form-filter-prime.svg)](https://packagist.org/packages/b2pweb/bdf-form-filter-prime)\n[![Total Downloads](https://img.shields.io/packagist/dt/b2pweb/bdf-form-filter-prime.svg)](https://packagist.org/packages/b2pweb/bdf-form-filter-prime)\n[![Type Coverage](https://shepherd.dev/github/b2pweb/bdf-form-filter-prime/coverage.svg)](https://shepherd.dev/github/b2pweb/bdf-form-filter-prime)\n\nSee :\n- [BDF Form](https://github.com/b2pweb/bdf-form)\n- [Prime](https://github.com/b2pweb/bdf-prime)\n\n## Installation using composer\n\n```\ncomposer require b2pweb/bdf-form-filter-prime\n```\n\n## Basic usage\n\nTo create a form filter, simply extends the class [`FilterForm`](src/FilterForm.php) and implements method `FilterForm::configureFilters()` :\n\n```php\n\u003c?php\n\nnamespace App\\Form;\n\nuse Bdf\\Form\\Filter\\FilterForm;\nuse Bdf\\Form\\Filter\\FilterFormBuilder;\n\nclass MyFilters extends FilterForm\n{\n    public function configureFilters(FilterFormBuilder $builder): void\n    {\n        // Build filter fields\n        // Will add a \"foo LIKE xxx%\"\n        $builder-\u003esearchBegins('foo');\n\n        // Will add a \"age BETWEEN ? AND ?\"\n        $builder-\u003eembedded('age', function ($builder) {\n            $builder-\u003einteger('0')-\u003esetter();\n            $builder-\u003einteger('1')-\u003esetter();\n        })-\u003ebetween();\n        \n        // Define a custom attribute name and operator\n        $builder-\u003estring('foo')-\u003ecriterion('bar')-\u003eoperator('\u003e=');\n    }\n}\n```\n\nNow, you can submit data to the form, apply filters to the query :\n\n```php\n\u003c?php\n\n// Instantiate the form (a container can be use for handle dependency injection)\n$form = new MyFilters();\n\n// Submit form\n// Note: if some constraints has been added, call `$form-\u003evalid()` and `$form-\u003eerror()` to check errors\n$form-\u003esubmit($request-\u003equery-\u003eall());\n\n// Get generated criteria\n$criteria = $form-\u003evalue();\n\n// Call prime with criteria\n$list = MyEntity::where($criteria-\u003eall())-\u003epaginate();\n```\n\n## Query helpers\n\nTwo helpers methods are available to handle Prime query without use directly the `Criteria` object :\n- `FilterForm::apply()` will apply the filters to the query instance\n- `FirstForm::query()` will create the query with filters\n\n```php\n\u003c?php\n\nnamespace App\\Form;\n\nuse Bdf\\Form\\Filter\\FilterForm;\nuse Bdf\\Form\\Filter\\FilterFormBuilder;\n\nclass MyFilters extends FilterForm\n{\n    public function configureFilters(FilterFormBuilder $builder): void\n    {\n        // Set the entity class (note: use $this instead of $builder)\n        $this-\u003esetEntity(Person::class);\n\n        // Define filters\n        $builder-\u003esearchBegins('firstName');\n        $builder-\u003esearchBegins('lastName');\n        $builder-\u003eembedded('age', function ($builder) {\n            $builder-\u003einteger('0')-\u003esetter();\n            $builder-\u003einteger('1')-\u003esetter();\n        })-\u003ebetween();\n    }\n}\n```\n\nTo use the helpers methods, it's necessary to inject the Prime's `ServiceLocator` instance on the constructor.\n\n```php\n\u003c?php\n\n// Get the form instance, using a container to inject prime\n$form = $container-\u003eget(MyFilters::class);\n\n// Submit form\n$form-\u003esubmit($request-\u003equery-\u003eall());\n\n// Use apply to modify the query\n$query = Person::builder();\n$entities = $form-\u003eapply($query)-\u003eall(); // Apply filters and execute query\n\n// Use directly query() method to create the filter query\n$entities = $form-\u003equery();\n```\n\n## Usage with mongodb\n\nThis library also supports Prime MongoDB filter. It requires b2pweb/bdf-prime-mongodb version 2.0.\nTo use, simply use `Bdf\\Form\\Filter\\MongoFilterForm` instead of `Bdf\\Form\\Filter\\FilterForm`, and change `$form-\u003esetEntity(...)` to `$form-\u003esetDocument()`.\n\n```php\n\u003c?php\n\nnamespace App\\Form;\n\nuse Bdf\\Form\\Filter\\MongoFilterForm;\nuse Bdf\\Form\\Filter\\FilterFormBuilder;\n\nclass MyFilters extends MongoFilterForm\n{\n    public function configureFilters(FilterFormBuilder $builder): void\n    {\n        // Set the document class (note: use $this instead of $builder)\n        $this-\u003esetEntity(Person::class);\n\n        // Define filters\n        $builder-\u003esearchBegins('firstName');\n        $builder-\u003esearchBegins('lastName');\n        $builder-\u003eembedded('age', function ($builder) {\n            $builder-\u003einteger('0')-\u003esetter();\n            $builder-\u003einteger('1')-\u003esetter();\n        })-\u003ebetween();\n    }\n}\n```\n\nThe usage is identical to basic prime entity usage.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-form-filter-prime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb2pweb%2Fbdf-form-filter-prime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-form-filter-prime/lists"}