Installation and Setup | laravel-tags | Spatie

 SPATIE

  Laravel Tags
===============

spatie.be/open-source

  [Docs](https://spatie.be/docs)  [Laravel-tags](https://spatie.be/docs/laravel-tags/v4)  Installation and Setup

 Version   v4   v3

 Other versions for crawler [v4](https://spatie.be/docs/laravel-tags/v4) [v3](https://spatie.be/docs/laravel-tags/v3)

- [ Introduction ](https://spatie.be/docs/laravel-tags/v4/introduction)
- [ Postcardware ](https://spatie.be/docs/laravel-tags/v4/postcardware)
- [ Requirements ](https://spatie.be/docs/laravel-tags/v4/requirements)
- [ Installation and Setup ](https://spatie.be/docs/laravel-tags/v4/installation-and-setup)
- [ Questions and issues ](https://spatie.be/docs/laravel-tags/v4/questions-and-issues)
- [ Changelog ](https://spatie.be/docs/laravel-tags/v4/changelog)
- [ About us ](https://spatie.be/docs/laravel-tags/v4/about-us)

Basic usage
-----------

- [ Using tags ](https://spatie.be/docs/laravel-tags/v4/basic-usage/using-tags)
- [ Retrieving tagged models ](https://spatie.be/docs/laravel-tags/v4/basic-usage/retrieving-tagged-models)

Advanced usage
--------------

- [ Adding translations ](https://spatie.be/docs/laravel-tags/v4/advanced-usage/adding-translations)
- [ Using types ](https://spatie.be/docs/laravel-tags/v4/advanced-usage/using-types)
- [ Sorting tags ](https://spatie.be/docs/laravel-tags/v4/advanced-usage/sorting-tags)
- [ Using your own tag model ](https://spatie.be/docs/laravel-tags/v4/advanced-usage/using-your-own-tag-model)
- [ Using another default locale ](https://spatie.be/docs/laravel-tags/v4/advanced-usage/using-another-default-locale)

 Installation and Setup
======================

You can install the package via composer:

```
composer require spatie/laravel-tags
```

You can publish the migration with:

```
php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="tags-migrations"
```

After the migration has been published you can create the `tags` and `taggables` tables by running the migrations:

```
php artisan migrate
```

You can optionally publish the config file with:

```
php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="tags-config"
```

This is the contents of the published config file:

```
return [

    /*
     * The given function generates a URL friendly "slug" from the tag name property before saving it.
     * Defaults to Str::slug (https://laravel.com/docs/master/helpers#method-str-slug)
     */
    'slugger' => null,

    /*
     * The fully qualified class name of the tag model.
     */
    'tag_model' => Spatie\Tags\Tag::class,

    /*
     * The name of the table associated with the taggable morph relation.
     */
    'taggable' => [
        'table_name' => 'taggables',
        'morph_name' => 'taggable',

        /*
         * The fully qualified class name of the pivot model.
         */
        'class_name' => Illuminate\Database\Eloquent\Relations\MorphPivot::class,
    ]
];
```
