Skip to content

dizatech/tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Tag Package

Latest Version on Packagist GitHub issues GitHub stars GitHub forks Total Downloads GitHub license

A laravel package for manage your tags, that use ajax, bootstrap, select2 and sweetalert2 for client side and use from many to many polymorphic relationship in models.

How to install and config dizatech/tag package?

composer require dizatech/tag

Install and publish files

Publish 'lacopa' packages pages:
php artisan tag:install --lacopa | --lacopa --force | -l -f | -lf

Publish empty pages for another projects:
php artisan tag:install --force | -f 

Use create and edit input components

Use this component in your 'create' pages:
<x-tag></x-tag>
OR set custom properties, defaults: label="برچسب‌ها" name="tags" page="create"
<x-tag label="برچسب‌ها" name="tags" page="create"></x-tag>

And use this component in your 'edit' pages:
<x-tag page="edit" id="{{ $post->id }}" $model="{{ get_class($post) }}"></x-tag>
Use this Blade tag in your page:
@tagScripts()

OR use this tag in script section of page:
@slot('script')

    @tagScripts()

@endslot

Use index, create and edit pages and customize this pages

  • If you use from lacopa add below code in your sidebar:

    @component('tag::components.sidebar.menu')@endcomponent
    
  • If you want to use tag package in another project, you can use /resources/views/vendor/tag directory

    Use below component in your create page structure:
    <x-tag-create></x-tag-create>
    
    Use below component in your edit page structure:
    <x-tag-edit tag="{{ $tag->id }}"></x-tag-edit>
    
    Use below component in your index page structure:
    <x-tag-index></x-tag-index>

Config files options

<?php

return [
    // Minimum Input Length for search keyword
    'minimumInputLength' => 2,

    // Recommended: Set your models that has many-to-many-polymorphic relation with Tag model
    'morphedByMany' => [
        // For example
        // 'articles'  => 'App\Models\Article',
    ],
];

// Notice: if you update 'morphedByMany' option, use this command each time
php artisan tag:reload

Set the Taggable Trait on models

<?php

namespace Modules\Course\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Dizatech\Tag\Services\Traits\Taggable;

class Post extends Model
{
    use HasFactory, SoftDeletes, Taggable;
}

Attach tags to models

<?php

$post->tags()->sync($request->tags);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published