Pharaonic
Loading...
Categorizable

# Why Categorizable?

Categorizable is a package provides an easy way to manage the model categories in Laravel.

# Installation

Install the latest version using Composer.

1composer require pharaonic/laravel-categorizable
2php artisan migrate

# Category Creation

This is how you can create a new multilingual category.

This package depends on Translatable, Sluggable.

1use Pharaonic\Laravel\Categorizable\Models\Category;
2 
3$category = Category::create(['type' => 'products']); // type is nullable
4$category->translateOrNew('en')->title = 'First Category'; // required
5$category->translateOrNew('en')->description = 'Description Here'; // nullable
6$category->save();

# Inclusion

This is what you should to include in your model file.

1namespace App\Models;
2 
3use Illuminate\Database\Eloquent\Model;
4use Pharaonic\Laravel\Categorizable\Traits\Categorizable;
5 
6class Product extends Model
7{
8 use Categorizable;
9 
10 protected $fillable = ['title'];
11}