{"id":20886547,"url":"https://github.com/hanieas/larasearch","last_synced_at":"2026-04-28T21:35:01.290Z","repository":{"id":208264824,"uuid":"721023295","full_name":"hanieas/Larasearch","owner":"hanieas","description":"This is a search package built to easily integrate with Laravel and the database.","archived":false,"fork":false,"pushed_at":"2023-11-20T15:54:59.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-08T02:55:01.822Z","etag":null,"topics":["database","laravel","php","search"],"latest_commit_sha":null,"homepage":"","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/hanieas.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-11-20T07:46:58.000Z","updated_at":"2024-05-18T09:53:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"c4c2b569-7c40-444b-9f73-37f4168dfcf5","html_url":"https://github.com/hanieas/Larasearch","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"e62e917f4f03d3240860dbe39aa9ce0455fb7f96"},"previous_names":["hanieas/larasearch"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hanieas/Larasearch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanieas%2FLarasearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanieas%2FLarasearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanieas%2FLarasearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanieas%2FLarasearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanieas","download_url":"https://codeload.github.com/hanieas/Larasearch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanieas%2FLarasearch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32400868,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"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":["database","laravel","php","search"],"created_at":"2024-11-18T08:17:17.871Z","updated_at":"2026-04-28T21:35:01.268Z","avatar_url":"https://github.com/hanieas.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LaraSearch\nThis is a search package built to easily integrate with Laravel and the database.\n\n# Installation\n```bash\ncomposer require hanieas/larasearch\n```\n\n# Usage\n\n## Prepare Model\n\nIn order to search through models you'll have to let them implement the Searchable interface.\n\n```php\nnamespace LaraSearch;\n\ninterface Searchable\n{\n    /**\n     * @return array\n     */\n    public function getColumnsForExactMatch(): array;\n\n    /**\n     * @return array\n     */\n    public function getColumnsForLikeMatch(): array;\n\n    /**\n     * @return array\n     */\n    public function getColumnsForBooleanMatch(): array;\n\n    /**\n     * @return array\n     */\n    public function getColumnsForPeriodMatch(): array;\n}\n```\nYou need to add the below 4 functions in your model to define type of search for columns of your table. This package will search items that are in the fillable attribute of the model.\n```php\nuse LaraSearch\\Searchable;\n\nclass User extends Model implements Searchable\n{\n    protected $fillable = [\n        'username',\n        'mobile',\n        'is_active',\n        'logged_in',\n    ];\n     \n    /**\n     * @return array\n     */\n    public function getColumnsForExactMatch(): array {\n        return [  \n            'mobile'\n        ];\n    }\n\n    /**\n     * @return array\n     */\n    public function getColumnsForLikeMatch(): array {\n         return [  \n            'username'\n        ];\n    }\n\n    /**\n     * @return array\n     */\n    public function getColumnsForBooleanMatch(): array {\n         return [  \n            'is_active'\n        ];\n    }\n\n    /**\n     * @return array\n     */\n    public function getColumnsForPeriodMatch(): array\n    {\n        return [  \n            'logged_in'\n        ];\n    }\n}\n```\n## Search\n\nWith the models prepared you can search them like this:\n```php\nclass UserController extends Controller\n{\n\n    /**\n     * @return JsonResponse\n     */\n    public function index(): JsonResponse\n    {\n        $users = new Search(Request()-\u003etoArray(), User::query())-\u003eget();\n        return response()-\u003ejson([\n            'users' =\u003e $users\n        ]);\n    }\n}\n```\nYou can easily search from the users' list by calling the below link:\n```\n{{address}}/users?username=hanie?mobile=?is_active=1?logged_in_from=2023-10-10?logged_in_to=2023-12-10\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanieas%2Flarasearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanieas%2Flarasearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanieas%2Flarasearch/lists"}