{"id":18154993,"url":"https://github.com/CakeDC/search-filter","last_synced_at":"2025-03-31T17:30:53.639Z","repository":{"id":256171862,"uuid":"854497355","full_name":"CakeDC/search-filter","owner":"CakeDC","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-03T01:49:03.000Z","size":159,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-12-03T02:41:29.354Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CakeDC.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2024-09-09T09:27:05.000Z","updated_at":"2024-09-17T07:40:05.000Z","dependencies_parsed_at":"2024-11-02T04:02:44.116Z","dependency_job_id":"1bb548de-0fbd-48ad-bf7e-566d54c7762c","html_url":"https://github.com/CakeDC/search-filter","commit_stats":null,"previous_names":["cakedc/search-filter"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Fsearch-filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Fsearch-filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Fsearch-filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CakeDC%2Fsearch-filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CakeDC","download_url":"https://codeload.github.com/CakeDC/search-filter/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246508873,"owners_count":20789064,"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","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-11-02T04:01:14.013Z","updated_at":"2025-03-31T17:30:53.326Z","avatar_url":"https://github.com/CakeDC.png","language":"PHP","funding_links":[],"categories":["Search","Plugins"],"sub_categories":["Search"],"readme":"CakeDC SearchFilter Plugin for CakePHP\n===================\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/CakeDC/search-filter/ci.yml?branch=main\u0026style=flat-square)](https://github.com/CakeDC/search-filter/actions?query=workflow%3ACI+branch%3Amain)\n[![Coverage Status](https://img.shields.io/codecov/c/gh/CakeDC/search-filter.svg?style=flat-square)](https://codecov.io/gh/CakeDC/search-filter)\n[![Downloads](https://poser.pugx.org/CakeDC/search-filter/d/total.png)](https://packagist.org/packages/CakeDC/search-filter)\n[![License](https://poser.pugx.org/CakeDC/search-filter/license.svg)](https://packagist.org/packages/CakeDC/search-filter)\n\nVersions and branches\n---------------------\n\n| CakePHP | CakeDC Users Plugin | Tag   | Notes |\n| :-------------: | :------------------------: | :--:  | :---- |\n| ^5.0            | [2.0](https://github.com/cakedc/users/tree/2.next-cake5)                      | 2.0.0 | stable |\n| ^4.5            | [1.0](https://github.com/cakedc/search-filter/tree/1.next-cake4)              | 1.0.0 | stable |\n\n\n## Overview\n\nThe SearchFilter plugin is a powerful and flexible solution for implementing advanced search functionality in CakePHP applications. It provides a robust set of tools for creating dynamic, user-friendly search interfaces with minimal effort.\n\n## Features\n\n- Dynamic filter generation based on database schema\n- Support for various filter types: string, numeric, date, datetime, boolean, and lookup (autocomplete)\n- Customizable filter conditions (equals, not equals, greater than, less than, between, etc.)\n- Vue.js based frontend for an interactive user experience\n- AJAX-powered autocomplete functionality for lookup filters\n- Easy integration with CakePHP's ORM for efficient query building\n- Extensible architecture allowing for custom filter types and conditions\n\n## Installation\n\nYou can install this plugin into your CakePHP application using [composer](https://getcomposer.org):\n\n```\ncomposer require cakedc/search-filter\n```\n\nThen, add the following line to your application's `src/Application.php` file:\n\n```php\n$this-\u003eaddPlugin('CakeDC.SearchFilter');\n```\n\n## Configuration\n\n* [Criteria List](docs/Criteria.md)\n* [Filters List](docs/Filters.md)\n\n## Basic Usage\n\n### Controller\n\nIn your controller, you can set up the search functionality like this:\n\n```php\nuse CakeDC\\SearchFilter\\Manager;\n\nclass PostsController extends AppController\n{\n    public function index()\n    {\n        $query = $this-\u003ePosts-\u003efind();\n\n        $manager = new Manager($this-\u003erequest);\n        $collection = $manager-\u003enewCollection();\n\n        // Add a general search filter\n        $collection-\u003eadd('search', $manager-\u003efilters()\n            -\u003enew('string')\n            -\u003esetConditions(new \\stdClass())\n            -\u003esetLabel('Search...')\n        );\n\n        // Add a complex name filter that searches across multiple fields\n        $collection-\u003eadd('name', $manager-\u003efilters()\n            -\u003enew('string')\n            -\u003esetLabel('Name')\n            -\u003esetCriterion(\n                $manager-\u003ecriterion()-\u003eor([\n                    $manager-\u003ebuildCriterion('title', 'string', $this-\u003ePosts),\n                    $manager-\u003ebuildCriterion('body', 'string', $this-\u003ePosts),\n                    $manager-\u003ebuildCriterion('author', 'string', $this-\u003ePosts),\n                ])\n            )\n        );\n\n        // Add a datetime filter for the 'created' field\n        $collection-\u003eadd('created', $manager-\u003efilters()\n            -\u003enew('datetime')\n            -\u003esetLabel('Created')\n            -\u003esetCriterion($manager-\u003ebuildCriterion('created', 'datetime', $this-\u003ePosts))\n        );\n\n        // Automatically add filters based on the table schema\n        $manager-\u003eappendFromSchema($collection, $this-\u003ePosts);\n\n        // Get the view configuration for the filters\n        $viewFields = $collection-\u003egetViewConfig();\n        $this-\u003eset('viewFields', $viewFields);\n\n        // Apply filters if search parameters are present in the request\n        if (!empty($this-\u003egetRequest()-\u003egetQuery()) \u0026\u0026 !empty($this-\u003egetRequest()-\u003egetQuery('f'))) {\n            $search = $manager-\u003eformatSearchData();\n            $this-\u003eset('values', $search);\n\n            // Add a custom 'multiple' filter using the CriteriaFilter\n            $this-\u003ePosts-\u003eaddFilter('multiple', [\n                'className' =\u003e 'CakeDC/SearchFilter.Criteria',\n                'criteria' =\u003e $collection-\u003egetCriteria(),\n            ]);\n\n            $filters = $manager-\u003eformatFinders($search);\n            $query = $query-\u003efind('filters', params: $filters);\n        }\n\n        // Paginate the results\n        $posts = $this-\u003epaginate($this-\u003eFilter-\u003eprg($query));\n        $this-\u003eset(compact('posts'));\n    }\n}\n```\n\nThis example demonstrates several key features of the SearchFilter plugin:\n\n1. Creating a new `Manager` instance and filter collection.\n2. Adding a general search filter that can be used for quick searches.\n3. Creating a complex filter that searches across multiple fields using `OrCriterion`.\n4. Adding a datetime filter for a specific field.\n5. Automatically generating filters based on the table schema.\n6. Applying filters when search parameters are present in the request.\n7. Using the `CriteriaFilter` for handling multiple filter criteria.\n\n### View\n\nIn your view, you can render the search component inside search form like this:\n\n```php\n\u003c?= $this-\u003eelement('CakeDC/SearchFilter.Search/v_search'); ?\u003e\n```\n\n```html\n\u003cscript\u003e\n    window._search.createMyApp(window._search.rootElemId)\n\u003c/script\u003e\n```\n\n## Advanced Usage\n\n### Custom Filter Types\n\n[Custom Range Filter implementation and integration](docs/CustomFilter.md)\n\n## Frontend Customization\n\nThe plugin uses Vue.js for the frontend. You can customize the look and feel by overriding the templates in your application:\n\n1. Copy the `templates/element/Search/v_templates.php` file from the plugin to your application's `templates/element/Search/` directory.\n2. Modify the templates as needed.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis plugin is licensed under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCakeDC%2Fsearch-filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCakeDC%2Fsearch-filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCakeDC%2Fsearch-filter/lists"}