{"id":21714619,"url":"https://github.com/lecturize/laravel-tags","last_synced_at":"2025-04-12T19:14:14.881Z","repository":{"id":57013448,"uuid":"41831690","full_name":"Lecturize/Laravel-Tags","owner":"Lecturize","description":"Simple way to tag Eloquent models in Laravel.","archived":false,"fork":false,"pushed_at":"2023-02-21T20:24:33.000Z","size":55,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T19:14:08.183Z","etag":null,"topics":[],"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/Lecturize.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2015-09-02T22:54:59.000Z","updated_at":"2022-04-26T13:03:02.000Z","dependencies_parsed_at":"2024-11-26T00:37:04.008Z","dependency_job_id":"f71fccce-4dce-4de6-91a5-2dfd80d13768","html_url":"https://github.com/Lecturize/Laravel-Tags","commit_stats":{"total_commits":77,"total_committers":3,"mean_commits":"25.666666666666668","dds":0.5064935064935066,"last_synced_commit":"d1d25bf500d0e93594992383e56ac51f058f38f3"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecturize%2FLaravel-Tags","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecturize%2FLaravel-Tags/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecturize%2FLaravel-Tags/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Lecturize%2FLaravel-Tags/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Lecturize","download_url":"https://codeload.github.com/Lecturize/Laravel-Tags/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618281,"owners_count":21134201,"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-26T00:37:01.271Z","updated_at":"2025-04-12T19:14:14.857Z","avatar_url":"https://github.com/Lecturize.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/lecturize/laravel-tags/v/stable)](https://packagist.org/packages/lecturize/laravel-tags)\n[![Total Downloads](https://poser.pugx.org/lecturize/laravel-tags/downloads)](https://packagist.org/packages/lecturize/laravel-tags)\n[![License](https://poser.pugx.org/lecturize/laravel-tags/license)](https://packagist.org/packages/lecturize/laravel-tags)\n\n# Laravel Tags\n\nSimple way to tag eloquent models in Laravel.\n\n## Installation\n\nRequire the package from your `composer.json` file\n\n```php\n\"require\": {\n    \"lecturize/laravel-tags\": \"^1.0\"\n}\n```\n\nand run `$ composer update` or both in one with `$ composer require lecturize/laravel-tags`.\n\n## Configuration \u0026 Migration\n\n```bash\n$ php artisan vendor:publish --provider=\"Cviebrock\\EloquentSluggable\\ServiceProvider\"\n$ php artisan vendor:publish --provider=\"Lecturize\\Tags\\TagsServiceProvider\"\n```\n\nThis will publish a `config/sluggable.php`, a `config/lecturize.php` and some migration files, that you'll have to run:\n\n```bash\n$ php artisan migrate\n```\n\nFor migrations to be properly published ensure that you have added the directory `database/migrations` to the classmap in your projects `composer.json`.\n\n## Usage\n\nFirst, add our `HasTags` trait to your model.\n        \n```php\n\u003c?php\n\nnamespace App\\Models;\n\nuse Lecturize\\Tags\\Traits\\HasTags;\n\nclass Post extends Model\n{\n    use HasTags;\n\n    // ...\n}\n?\u003e\n```\n\n##### Get all tags for a model\n```php\n$tags = $model-\u003etags();\n```\n\n##### Check if model is tagged with a given tag\n```php\n$tags = $model-\u003ehasTag('Check');\n```\n\n##### Add one or more tags\n```php\n$tags = $model-\u003etag('My First Tag');\n$tags = $model-\u003etag(['First', 'Second', 'Third']);\n```\n\n##### Remove given tags from model\n```php\n$tags = $model-\u003euntag('Remove');\n```\n\n##### Replace all existing tags for a model with new ones\n```php\n$tags = $model-\u003eretag('A New Tag');\n$tags = $model-\u003eretag(['Fourth', 'Fifth', 'Sixth']);\n```\n\n##### Remove all existing tags from model\n```php\n$tags = $model-\u003edetag();\n```\n\n##### Get a list of all tags\n```php\n$tags = $model-\u003elistTags();\n```\n\nThis is a convenience method for `$model-\u003etags-\u003epluck('tag')`\n\n##### Scopes\n\nThere are two scopes included to fluently query models (e.g. Posts) with given tags.\n\n```php\n$posts = Post::withTag('My First Tag')-\u003eget();\n$posts = Post::withTags(['First', 'Second', 'Third'])-\u003eget();\n```\n\n## License\n\nLicensed under [MIT license](http://opensource.org/licenses/MIT).\n\n## Author\n\n**Handcrafted with love by [Alexander Manfred Poellmann](https://twitter.com/AMPoellmann) in Vienna \u0026amp; Rome.**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecturize%2Flaravel-tags","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flecturize%2Flaravel-tags","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flecturize%2Flaravel-tags/lists"}