Require this package, with Composer, in the root directory of your project.
$ composer require uptoolkit/laravel-categories
To get started, you'll need to publish the vendor assets and migrate:
php artisan vendor:publish --provider="Uptoolkit\Categories\CategoriesServiceProvider" && php artisan migrate
Check lazychaser/laravel-nestedset to learn how to create, update, delete, etc. categories.
<?php
namespace App;
use Uptoolkit\Categories\Traits\HasCategories;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
{
use HasCategories;
}
$post->categoriesList();
$post->syncCategories([Category::find(1), Category::find(2), Category::find(3)]);
$post->syncCategories([]);
$post->syncCategories([Category::find(1), Category::find(3)]);
$post->assignCategory(Category::find(1));
$post->removeCategory(Category::find(1));
Category::first()->entries(Post::class)->get();
$ phpunit
If you discover a security vulnerability within this package, please send an e-mail to [email protected]. All security vulnerabilities will be promptly addressed.