Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

Category and Tags are often useful while working working with Laravel Model. This solution enable categories and tags for any Models in Laravel. Here step by step setup is given below.

Content

  1. Installtion
  2. Publish Assets and Migration
  3. Use Trait in model
  4. Call from anywhere
  5. Display in blade

Step1: Installation

composer require aammui/laravel-taggable

Step2: Publish Migrations assets

php artisan vendor:publish --provider="Aammui\LaravelTaggable\LaravelTaggableServiceProvider"
php artisan migrate

Step3: Use Traits

Add HasCatgory and HasTag Traits in your model.

<?php 

namespace App;

use Aammui\LaravelTaggable\Traits\HasCategory;
use Aammui\LaravelTaggable\Traits\HasTag;

class Post extends Model {
    use HasCategory, HasTag;
}

Step4: Call from anywhere.

<?php
$post = Post::create(['name'=>'Post']);
$post->addTag('Tags');
$post->addTag(['Tags','Category']);
$post->addCategory('Category');
$post->addCategory(['Category', 'Laravel Category']);

Step5: Display In Blade

<ul>
@foreach($posts->category as $item)
<li>{{$item->name}}</li>
@endforeach
</ul>

About

Provide Categories and Tags to any laravel Models.

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages