binomeway / nova-taxonomies-tool
This package is abandoned and no longer maintained.
No replacement package was suggested.
A Laravel Nova tool to manage taxonomies.
v1.3.0
2021-08-22 18:47 UTC
Requires
- php: >=8.0
- spatie/laravel-package-tools: ^1.9
- spatie/laravel-tags: ^4.0
- spatie/nova-tags-field: ^3.3
README
Nova Taxonomies
This package uses spatie/laravel-tags and spatie/nova-tags-field.
Installation
Refer to the spatie/laravel-tags documentation to prepare your model and publish the migrations needed.
Register the tool in your NovaServiceProvider.php
public function tools(){ return [ \BinomeWay\NovaTaxonomiesTool\NovaTaxonomiesTool::make(), ]; }
Usage
Tag Types
Add your tag types using the Nova Panel or register them from a ServiceProvider.
use \BinomeWay\NovaTaxonomiesTool\Facades\Taxonomies; public function boot() { Taxonomies::addType('categories', 'Categories'); // or multiple Taxonomies::addTypes([ 'name' => 'Display Name', 'colors' => 'Colors', 'types' => 'Types', ]); }
Actions
Update multiple tags
use BinomeWay\NovaTaxonomiesTool\Nova\Actions\UpdateTag; function actions(Request $request) { return [ // This will result in have the default button Update Tag UpdateTag::make('categories'), // Update Tag // You can Override the label using the constructor or the 'withLabel' method UpdateTag::make('categories', 'Categories') // Update Categories // alternative ->withLabel('Categories'), // Will produce same result: Update Categories // If you want to override the name entirely use the 'withName' method UpdateTag::make('categories')->withName('My Action Name') ]; }
Update a single tag
Force a single tag selection. This will show a select field instead.
use BinomeWay\NovaTaxonomiesTool\Nova\Actions\UpdateSingleTag; public function actions(Request $request) { return [ UpdateSingleTag::make('status', 'Status'), ]; }
You can use the same methods as above to customise the displayed name.
Filters
Filter by a single tag
Filter resources by a single tag.
use BinomeWay\NovaTaxonomiesTool\Nova\Filters\SingleTag; public function filters(Request $request) { return [ SingleTag::make() ->withName(__('By Status')) // Override the displayed name ->withTagType('status') ]; }
Filter by multiple tags
Filter resources by a multiple tags at once.
use BinomeWay\NovaTaxonomiesTool\Nova\Filters\MultiTags; public function filters(Request $request) { return [ MultiTags::make() ->withName(__('By Position')) ->withTagType('page-position'), ]; }