Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Aug 24, 2018
1 parent 82cb012 commit a79d337
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,60 @@ This package contains a Nova field to add tags to resources. Under the hood it u

![screenshot of the tags field](https://spatie.github.io/nova-tags-field/screenshot.png)

## Requirements

This nova field requires a database that supports json fields such as MySQL 5.7.8 or higher.

## Installation

You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
First you must install [spatie/laravel-tags](https://github.com/spatie/laravel-tags) into your Laravel app. Here are [the installation instructions](https://docs.spatie.be/laravel-tags/v2/installation-and-setup) for that package.

Next, you can install this package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:

```bash
composer require spatie/nova-tags-field
```

Next up, you must register the tool with Nova. This is typically done in the `tools` method of the `NovaServiceProvider`.
## Usage

To make an Eloquent model taggable just add the `\Spatie\Tags\HasTags` trait to it:

```php
class BlogPost extends \Illuminate\Database\Eloquent\Model
{
use \Spatie\Tags\HasTags;

...
}
```

Next you can use the `Spatie\TagsField\Tags` field in your Nova resource:

```php
// in app/Providers/NovaServiceProvider.php
namespace App\Nova;

// ...

public function tools()
class BlogPost extends Resource
{
return [
// ...
new \Spatie\TagsField\Tool(),
];
// ...

public function fields(Request $request)
{
return [
// ...

Tags::make('Tags'),

// ...
];
}
}
```

## Usage
Now you can view and add tags on the blog posts screen in your Nova app. Any tags will be saved in the `tags` table.

Click on the "nova-tags-field" menu item in your Nova app to see the tool provided by this package.
For more info on how to work with the save tags, head over to [the docs of spatie/laravel-tags](https://docs.spatie.be/laravel-tags/).

### Testing

Expand Down

0 comments on commit a79d337

Please sign in to comment.