{"id":28383155,"url":"https://github.com/swisnl/laravel-fulltext","last_synced_at":"2025-06-25T07:30:49.174Z","repository":{"id":49047558,"uuid":"73065642","full_name":"swisnl/laravel-fulltext","owner":"swisnl","description":"Fulltext indexing and searching for Laravel","archived":false,"fork":false,"pushed_at":"2025-02-24T09:07:20.000Z","size":175,"stargazers_count":184,"open_issues_count":5,"forks_count":24,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-06-06T05:30:33.317Z","etag":null,"topics":["hacktoberfest"],"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/swisnl.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-07T10:06:19.000Z","updated_at":"2025-05-22T10:30:00.000Z","dependencies_parsed_at":"2024-06-18T13:55:34.752Z","dependency_job_id":null,"html_url":"https://github.com/swisnl/laravel-fulltext","commit_stats":{"total_commits":120,"total_committers":13,"mean_commits":9.23076923076923,"dds":0.4666666666666667,"last_synced_commit":"7c09c90ae22769a0b7b0219b409172eb300f1477"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/swisnl/laravel-fulltext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisnl%2Flaravel-fulltext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisnl%2Flaravel-fulltext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisnl%2Flaravel-fulltext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisnl%2Flaravel-fulltext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swisnl","download_url":"https://codeload.github.com/swisnl/laravel-fulltext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swisnl%2Flaravel-fulltext/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261826883,"owners_count":23215660,"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":["hacktoberfest"],"created_at":"2025-05-30T05:11:59.346Z","updated_at":"2025-06-25T07:30:49.168Z","avatar_url":"https://github.com/swisnl.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel fulltext index and search\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Buy us a tree][ico-treeware]][link-treeware]\n[![Build Status][ico-github-actions]][link-github-actions]\n[![Total Downloads][ico-downloads]][link-downloads]\n[![Made by SWIS][ico-swis]][link-swis]\n\nThis package creates a MySQL fulltext index for models and enables you to search through those.\n\n## Install\n\n1. Install with composer ``composer require swisnl/laravel-fulltext``\n2. Publish migrations and config ``php artisan vendor:publish --tag=laravel-fulltext``\n3. Migrate the database ``php artisan migrate``\n\n\n## Usage\n\nThe package uses a model observer to update the index when models change. If you want to run a full index you can use the console commands.\n\n### Models\n\nAdd the ``Indexable`` trait to the model you want to have indexed and define the columns you'd like to index as title and content.\n\n#### Example\n```php\nclass Country extends Model\n{\n\n    use \\Swis\\Laravel\\Fulltext\\Indexable;\n\n    protected $indexContentColumns = ['biographies.name', 'political_situation', 'elections'];\n    protected $indexTitleColumns = ['name', 'governmental_type'];\n\n}\n```\n\nYou can use a dot notation to query relationships for the model, like ``biographies.name``.\n\n\n### Searching\n\nYou can search using the Search class.\n\n```php\n$search = new \\Swis\\Laravel\\Fulltext\\Search();\n$search-\u003erun('europe');\n```\n\nThis will return a Collection of ``\\Swis\\Laravel\\Fulltext\\IndexedRecord`` which contain the models in the Polymorphic relation ``indexable``.\n\nIf you only want to search a certain model you can use ``$search-\u003erunForClass('europe', Country::class);``. This will only return results from that model.\n\n\n### Artisan Commands\n\n\n#### laravel-fulltext:all\n\nIndex all models for a certain class.\n```bash\nphp artisan laravel-fulltext:all \\\\App\\\\Models\\\\Country\n```\n\n#### laravel-fulltext:one\nIndex a single model of a certain class.\n```bash\nphp artisan laravel-fulltext:one \\\\App\\\\Models\\\\Country 4\n```\n\n\n## Options\n\n### db_connection\n\nChoose the database connection to use, defaults to the default database connection. When you are NOT using the default database connection, this MUST be set before running the migration to work correctly.\n\n### weight.title weight.content\n\nResults on ``title`` or ``content`` are weighted in the results. Search result score is multiplied by the weight in this config.\n\n### enable_wildcards\n\nEnable wildcard after words. So when searching for example  ``car`` it will also match ``carbon``.\n\n### exclude_feature_enabled\n\nThis feature excludes some rows from being returned. Enable this when you have a flag in your model which determines whether this record must be returned in search queries or not. By default this feature is disabled.\n\n### exclude_records_column_name\n\nThe column name for that property (which acts as a flag). This must match the exact column name at the table.\n\n#### An example of using this feature\n\nIf you have a blog and then added this search functionality to your blog to search through your blog posts. Sometimes you do not want some posts to appear in the search result, for example when a post is not published yet. This feature helps you to do it.\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n```bash\ncomposer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email security@swis.nl instead of using the issue tracker.\n\n## Credits\n\n- [Björn Brala][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\nThis package is [Treeware](https://treeware.earth). If you use it in production, then we ask that you [**buy the world a tree**][link-treeware] to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.\n\n## SWIS :heart: Open Source\n\n[SWIS][link-swis] is a web agency from Leiden, the Netherlands. We love working with open source software.\n\n[ico-version]: https://img.shields.io/packagist/v/swisnl/laravel-fulltext.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-treeware]: https://img.shields.io/badge/Treeware-%F0%9F%8C%B3-lightgreen.svg?style=flat-square\n[ico-github-actions]: https://img.shields.io/github/actions/workflow/status/swisnl/laravel-fulltext/run-tests.yml?label=tests\u0026branch=master\u0026style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/swisnl/laravel-fulltext.svg?style=flat-square\n[ico-swis]: https://img.shields.io/badge/%F0%9F%9A%80-made%20by%20SWIS-%230737A9.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/swisnl/laravel-fulltext\n[link-github-actions]: https://github.com/swisnl/laravel-fulltext/actions/workflows/run-tests.yml\n[link-downloads]: https://packagist.org/packages/swisnl/laravel-fulltext\n[link-treeware]: https://plant.treeware.earth/swisnl/laravel-fulltext\n[link-author]: https://github.com/swisnl\n[link-contributors]: ../../contributors\n[link-swis]: https://www.swis.nl\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisnl%2Flaravel-fulltext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswisnl%2Flaravel-fulltext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswisnl%2Flaravel-fulltext/lists"}