{"id":15764718,"url":"https://github.com/ctf0/easy-searchable","last_synced_at":"2026-05-03T06:36:47.806Z","repository":{"id":56959919,"uuid":"267816176","full_name":"ctf0/easy-searchable","owner":"ctf0","description":"search your model \u0026 relation with ease","archived":false,"fork":false,"pushed_at":"2023-01-03T23:16:10.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T12:19:46.051Z","etag":null,"topics":["laravel","model","php","relational-databases","search"],"latest_commit_sha":null,"homepage":"","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/ctf0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"ctf0"}},"created_at":"2020-05-29T09:17:08.000Z","updated_at":"2023-01-03T23:05:50.000Z","dependencies_parsed_at":"2023-02-01T12:50:16.965Z","dependency_job_id":null,"html_url":"https://github.com/ctf0/easy-searchable","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Feasy-searchable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Feasy-searchable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Feasy-searchable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Feasy-searchable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctf0","download_url":"https://codeload.github.com/ctf0/easy-searchable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246451282,"owners_count":20779598,"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":["laravel","model","php","relational-databases","search"],"created_at":"2024-10-04T12:04:31.187Z","updated_at":"2026-05-03T06:36:42.786Z","avatar_url":"https://github.com/ctf0.png","language":"PHP","funding_links":["https://github.com/sponsors/ctf0"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    EasySearchable\n    \u003cbr\u003e\n    \u003ca href=\"https://packagist.org/packages/ctf0/easy-searchable\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/ctf0/easy-searchable.svg\" alt=\"Latest Stable Version\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/ctf0/easy-searchable\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/ctf0/easy-searchable.svg\" alt=\"Total Downloads\"/\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n## Installation\n\n``` bash\ncomposer require ctf0/easy-searchable\n```\n\n# Setup\n\n\u003e also check https://github.com/laravie/query-filter#search-queries\n\n- in ur model add\n\n```php\nuse ctf0\\EasySearchable\\Traits\\HasSearch;\n\nclass Post extends Model\n{\n    use HasSearch;\n\n    // searched attributes\n    //\n    // when empty, all model fields will be searched\n    // except \"dates, primary_key, hidden\"\n    public $searchableAttributes = [];\n\n    // or have a complete freedom and directly use\n    public function getSearchableAttributes()\n    {\n        return [\n            'name-\u003e' . app()-\u003egetLocale(),\n            // ...\n        ];\n    }\n\n    // ignore attributes\n    //\n    // so instead of listing all the needed columns in `$searchableAttributes`\n    // you can ignore the ones you don't need here\n    public $searchableAttributesIgnore = [];\n\n    // searched relations\n    //\n    // when empty, no relation will be searched\n    // * under each relation add the '$searchableAttributes' and we will pick them up automatically\n    // * doesn't support nested relations\n    public $searchableRelations  = [];\n\n    // we search using the full sentence,\n    // however if you prefer to search by words, then use\n    public $replaceSpace = true;\n\n    // to force searching dates\n    public $searchableDates = true;\n}\n```\n\n# Usage\n\n```php\n// auto search in model \u0026 relations attributes\nPost::search('search for something')-\u003eget();\n\n// to strict search even further, wrap the text with either `'` or `\"`\nPost::search('\"search for something\"')-\u003eget();\n\n// search in specific fields\nPost::search('search for something', ['columnName','relation.columnName'])-\u003eget();\n```\n\n## Morph Relation Search\n\neither use \n- https://github.com/laravie/query-filter#search-with-morph-relations **\"which will disable the auto search the trait does\"**\n- create a scope and chain it to ur search call ex.\n```php\n// model\npublic function scopeWorkerSearch($query, $searchTerm)\n{\n    return $query-\u003eorWhereHasMorph(\n        'workerable', // name of the morph relation\n        '*',\n        function ($q) use ($searchTerm) {\n            $q-\u003esearch($searchTerm);\n        }\n    );\n}\n\n// controller\nreturn $query-\u003esearch($text)-\u003eworkerSearch($text);\n```\n\n\u003cbr\u003e\n\n### Security\n\nIf you discover any security-related issues, please email [ctf0-dev@protonmail.com](mailto:ctf0-dev@protonmail.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctf0%2Feasy-searchable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctf0%2Feasy-searchable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctf0%2Feasy-searchable/lists"}