ctf0 / tagos
GUI to manage tags in laravel based on spatie/laravel-tags
Fund package maintenance!
ctf0
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 3
Forks: 1
Open Issues: 0
Language:Vue
Requires
- ctf0/package-changelog: *
- illuminate/support: >=5.5 <9.0
- spatie/laravel-tags: *
README
A Tag Editor and Selector based on spatie/laravel-tags.
Editor
Selector
- package requires Laravel v5.5+
Installation
-
composer require ctf0/tagos
-
publish the package assets with
php artisan vendor:publish --provider="ctf0\Tagos\TagosServiceProvider"
php artisan vendor:publish --provider="Spatie\Tags\TagsServiceProvider" --tag="migrations"
-
after installation, run
php artisan tagos:setup
to add- package routes to
routes/web.php
- package assets compiling to
webpack.mix.js
- package routes to
-
install dependencies
yarn add vue vue-awesome@v2 vue-notif vue-tippy@v2 axios fuse.js
-
add this one liner to your main js file and run
npm run watch
to compile yourjs/css
files.- if you are having issues Check
// app.js window.Vue = require('vue') require('../vendor/Tagos/js/manager') new Vue({ el: '#app' })
Features
-
tags editor & selector.
-
show tag suggestion as you type.
-
easily add new tag name & type.
-
show tagged items by tag & by type.
-
search for tags by name in tags index.
-
shortcuts
interactions keyboard mouse (click) show all tags (input) 2x add new tag enter * hide tags list esc anywhere
Usage
-
migrate the tags table with
php artisan migrate
-
there is also a seeder to quickly get you going
// database/seeds/DatabaseSeeder.php class DatabaseSeeder extends Seeder { /** * Run the database seeds. */ public function run() { //... $this->call(TagsTableSeeder::class); } }
-
add
HasTags
trait to your model ex.post
use ctf0\Tagos\Traits\HasTags; use Illuminate\Database\Eloquent\Model; class Post extends Model { use HasTags; }
Get All tags
app('cache')->get('tagos');
Attaching Tags
-
show the tag selector
-
ex.
posts create view
@include('Tagos::partials.add')
-
ex.
posts edit view
@include('Tagos::partials.add', ['old' => app('tagos')->getModelTags($post)])
-
-
save the tags
-
store()
$model = Post::create([...]); app('tagos')->saveTags($model, $request);
-
update()
$model = Post::find($id)->update([...]); app('tagos')->saveTags($model, $request);
-
Display Model Tags
@include('Tagos::partials.display', [ 'tags' => $post->tags, 'showType' => true // whether to show the tag type or not ])
Routes
Method | URL | Name | Action |
---|---|---|---|
GET | tags/editor | tagos.editor | \ctf0\Tagos\Controllers\TagosController@editor |
GET | tags | tagos.index | \ctf0\Tagos\Controllers\TagosController@index |
GET | tags/type/{type} | tagos.index_type | \ctf0\Tagos\Controllers\TagosController@indexByType |
GET | tags/{slug} | tagos.show | \ctf0\Tagos\Controllers\TagosController@show |
GET | tags/type/{type}/tag/{slug} | tagos.show_type | \ctf0\Tagos\Controllers\TagosController@showByType |