1. Go to this page and download the library: Download codicastudio/tags-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codicastudio / tags-manager example snippets
class BlogPost extends \Illuminate\Database\Eloquent\Model
{
use \Spatie\Tags\HasTags;
...
}
namespace App\Nova;
use Spatie\TagsField\Tags;
class BlogPost extends Resource
{
// ...
public function fields(Request $request)
{
return [
// ...
Tags::make('Tags'),
// ...
];
}
}
// in your Nova resource
public function fields(Request $request)
{
return [
// ...
Tags::make('Tags')->type('my-special-type'),
// ...
];
}
// in your Nova resource
public function fields(Request $request)
{
return [
// ...
Tags::make('Tags')->single(),
// ...
];
}
namespace App\Nova;
use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;
use Spatie\Tags\Tag as TagModel;
class Tag extends Resource
{
public static $model = TagModel::class;
public static $title = 'name';
public static $search = [
'name',
];
public function fields(Request $request)
{
return [
Text::make('Name')->sortable(),
];
}
}
Tags::make('Tags')->withLinkToTagResource() // The resource App\Nova\Tag will be used
Tags::make('Tags')->withLinkToTagResource(\Custom\CustomTag::class) // The resource \Custom\CustomTag will be used
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.