{"id":13396092,"url":"https://github.com/spatie/laravel-tags","last_synced_at":"2026-02-21T17:05:06.719Z","repository":{"id":40589349,"uuid":"71335427","full_name":"spatie/laravel-tags","owner":"spatie","description":"Add tags and taggable behaviour to your Laravel app","archived":false,"fork":false,"pushed_at":"2026-01-31T09:47:22.000Z","size":1438,"stargazers_count":1727,"open_issues_count":1,"forks_count":292,"subscribers_count":16,"default_branch":"main","last_synced_at":"2026-01-31T22:27:21.251Z","etag":null,"topics":["database","eloquent","laravel","php","tags"],"latest_commit_sha":null,"homepage":"https://freek.dev/609-an-opinionated-tagging-package-for-laravel-apps","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/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"spatie"}},"created_at":"2016-10-19T08:28:05.000Z","updated_at":"2026-01-31T09:47:18.000Z","dependencies_parsed_at":"2023-02-16T09:15:52.684Z","dependency_job_id":"76059ef6-202b-4a3f-8a8d-471138cc44b8","html_url":"https://github.com/spatie/laravel-tags","commit_stats":{"total_commits":384,"total_committers":98,"mean_commits":"3.9183673469387754","dds":"0.39583333333333337","last_synced_commit":"956dc06e48ff5adae60ae27c76910f1f8eb46dba"},"previous_names":[],"tags_count":81,"template":false,"template_full_name":null,"purl":"pkg:github/spatie/laravel-tags","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/laravel-tags/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Flaravel-tags/sbom","scorecard":{"id":840626,"data":{"date":"2025-08-11","repo":{"name":"github.com/spatie/laravel-tags","commit":"884cfe480033edfc9b4af0d5b4489236627b7e23"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.6,"checks":[{"name":"Code-Review","score":4,"reason":"Found 10/24 approved changesets -- score normalized to 4","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"1 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.md:0","Info: FSF or OSI recognized license: MIT License: LICENSE.md:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 17 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T20:24:05.261Z","repository_id":40589349,"created_at":"2025-08-23T20:24:05.261Z","updated_at":"2025-08-23T20:24:05.261Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29688218,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T15:51:39.154Z","status":"ssl_error","status_checked_at":"2026-02-21T15:49:03.425Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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","eloquent","laravel","php","tags"],"created_at":"2024-07-30T18:00:39.858Z","updated_at":"2026-02-21T17:05:06.714Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie"],"categories":["Popular Packages","PHP","Plugins"],"sub_categories":["Laravel","Integrations \u0026 API"],"readme":"\u003cdiv align=\"left\"\u003e\n    \u003ca href=\"https://spatie.be/open-source?utm_source=github\u0026utm_medium=banner\u0026utm_campaign=laravel-tags\"\u003e\n      \u003cpicture\u003e\n        \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://spatie.be/packages/header/laravel-tags/html/dark.webp\"\u003e\n        \u003cimg alt=\"Logo for laravel-tags\" src=\"https://spatie.be/packages/header/laravel-tags/html/light.webp\"\u003e\n      \u003c/picture\u003e\n    \u003c/a\u003e\n\n\u003ch1\u003eAdd tags and taggable behaviour to a Laravel app\u003c/h1\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/laravel-tags.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-tags)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/spatie/laravel-tags/run-tests.yml?label=tests)\n[![Total Downloads](https://img.shields.io/packagist/dt/spatie/laravel-tags.svg?style=flat-square)](https://packagist.org/packages/spatie/laravel-tags)\n    \n\u003c/div\u003e\n\nThis package offers taggable behaviour for your models. After the package is installed the only thing you have to do is add the `HasTags` trait to an Eloquent model to make it taggable. \n\nBut we didn't stop with the regular tagging capabilities you find in every package. Laravel Tags comes with batteries included. Out of the box it has support for [translating tags](https://docs.spatie.be/laravel-tags/v4/advanced-usage/adding-translations), [multiple tag types](https://docs.spatie.be/laravel-tags/v4/advanced-usage/using-types) and [sorting capabilities](https://docs.spatie.be/laravel-tags/v4/advanced-usage/sorting-tags).\n\nYou'll find the documentation on https://spatie.be/docs/laravel-tags.\n\nHere are some code examples:\n\n```php\n// apply HasTags trait to a model\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Spatie\\Tags\\HasTags;\n\nclass NewsItem extends Model\n{\n    use HasTags;\n    \n    // ...\n}\n```\n\n```php\n\n// create a model with some tags\n$newsItem = NewsItem::create([\n   'name' =\u003e 'The Article Title',\n   'tags' =\u003e ['first tag', 'second tag'], //tags will be created if they don't exist\n]);\n\n// attaching tags\n$newsItem-\u003eattachTag('third tag');\n$newsItem-\u003eattachTag('third tag','some_type');\n$newsItem-\u003eattachTags(['fourth tag', 'fifth tag']);\n$newsItem-\u003eattachTags(['fourth_tag','fifth_tag'],'some_type');\n\n// detaching tags\n$newsItem-\u003edetachTag('third tag');\n$newsItem-\u003edetachTag('third tag','some_type');\n$newsItem-\u003edetachTags(['fourth tag', 'fifth tag']);\n$newsItem-\u003edetachTags(['fourth tag', 'fifth tag'],'some_type');\n\n// get all tags of a model\n$newsItem-\u003etags;\n\n// syncing tags\n$newsItem-\u003esyncTags(['first tag', 'second tag']); // all other tags on this model will be detached\n\n// syncing tags with a type\n$newsItem-\u003esyncTagsWithType(['category 1', 'category 2'], 'categories'); \n$newsItem-\u003esyncTagsWithType(['topic 1', 'topic 2'], 'topics'); \n\n// retrieving tags with a type\n$newsItem-\u003etagsWithType('categories'); \n$newsItem-\u003etagsWithType('topics'); \n\n// retrieving models that have any of the given tags\nNewsItem::withAnyTags(['first tag', 'second tag'])-\u003eget();\n\n// retrieve models that have all of the given tags\nNewsItem::withAllTags(['first tag', 'second tag'])-\u003eget();\n\n// retrieve models that don't have any of the given tags\nNewsItem::withoutTags(['first tag', 'second tag'])-\u003eget();\n\n// translating a tag\n$tag = Tag::findOrCreate('my tag');\n$tag-\u003esetTranslation('name', 'fr', 'mon tag');\n$tag-\u003esetTranslation('name', 'nl', 'mijn tag');\n$tag-\u003esave();\n\n// getting translations\n$tag-\u003etranslate('name'); //returns my name\n$tag-\u003etranslate('name', 'fr'); //returns mon tag (optional locale param)\n\n// convenient translations through taggable models\n$newsItem-\u003etagsTranslated();// returns tags with slug_translated and name_translated properties\n$newsItem-\u003etagsTranslated('fr');// returns tags with slug_translated and name_translated properties set for specified locale\n\n// using tag types\n$tag = Tag::findOrCreate('tag 1', 'my type');\n\n// tags have slugs\n$tag = Tag::findOrCreate('yet another tag');\n$tag-\u003eslug; //returns \"yet-another-tag\"\n\n// tags are sortable\n$tag = Tag::findOrCreate('my tag');\n$tag-\u003eorder_column; //returns 1\n$tag2 = Tag::findOrCreate('another tag');\n$tag2-\u003eorder_column; //returns 2\n\n// manipulating the order of tags\n$tag-\u003eswapOrder($anotherTag);\n\n// checking if a model has a tag\n$newsItem-\u003ehasTag('first tag');\n$newsItem-\u003ehasTag('first tag', 'some_type');\n\n// Retrieve models that have tags of a \nModel::withAnyTagsOfType('type');\nModel::withAnyTagsOfType(['first type', 'second type']);\n```\n\nSpatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).\n\n## Support us\n\n[\u003cimg src=\"https://github-ads.s3.eu-central-1.amazonaws.com/laravel-tags.jpg?t=1\" width=\"419px\" /\u003e](https://spatie.be/github-ad-click/laravel-tags)\n\nWe invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).\n\nWe highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).\n\n## Requirements\n\nThis package requires Laravel 8 or higher, PHP 8 or higher, and a database that supports `json` fields and MySQL compatible functions.\n\n## Installation\n\nYou can install the package via composer:\n\n``` bash\ncomposer require spatie/laravel-tags\n```\n\nThe package will automatically register itself.\n\nYou can publish the migration with:\n```bash\nphp artisan vendor:publish --provider=\"Spatie\\Tags\\TagsServiceProvider\" --tag=\"tags-migrations\"\n```\n\nAfter the migration has been published you can create the `tags` and `taggables` tables by running the migrations:\n\n```bash\nphp artisan migrate\n```\n\nYou can optionally publish the config file with:\n```bash\nphp artisan vendor:publish --provider=\"Spatie\\Tags\\TagsServiceProvider\" --tag=\"tags-config\"\n```\n\nThis is the contents of the published config file:\n\n```php\nreturn [\n\n    /*\n     * The given function generates a URL friendly \"slug\" from the tag name property before saving it.\n     * Defaults to Str::slug (https://laravel.com/docs/5.8/helpers#method-str-slug)\n     */\n    'slugger' =\u003e null, \n];\n```\n\n## Documentation\nYou'll find the documentation on [https://docs.spatie.be/laravel-tags/v4](https://spatie.be/docs/laravel-tags).\n\nFind yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improving the `laravel-tags` package? Feel free to [create an issue on GitHub](https://github.com/spatie/laravel-tags/issues), we'll try to address it as soon as possible.\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Testing\n\n1. Copy `phpunit.xml.dist` to `phpunit.xml` and fill in your database credentials.\n2. Run `composer test`.\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security\n\nIf you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker.\n\n## Postcardware\n\nYou're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.\n\nOur address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium.\n\nWe publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards).\n\n## Credits\n\n- [Freek Van der Herten](https://github.com/freekmurze)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Flaravel-tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Flaravel-tags/lists"}