Download the PHP package mayoz/laravel-categorizable without Composer
On this page you can find all versions of the php package mayoz/laravel-categorizable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mayoz/laravel-categorizable
More information about mayoz/laravel-categorizable
Files in mayoz/laravel-categorizable
Package laravel-categorizable
Short Description Polymorphic categorizable for Laravel
License MIT
Informations about the package laravel-categorizable
Laravel Categorizable
Easily add the ability to category your Eloquent models in Laravel 5.
- Installation
- Configuration
- Usage
- Extending
- License
Installation
You can install the package via composer:
Register the service provider in your config/app.php
configuration file:
You can publish the migration with:
The migration has been published you can create the categories
and categorizable
tables. You are feel free for added new fields that you need. After, run the migrations:
Usage
Suppose, you have the Post
model as follows:
Associate new categories for the Post
model:
Now, the post
model is associated with categories ids of 1
, 2
, 3
, 4
and 5
.
Remove the existing category association for the Post
model:
The post
model is associated with categories ids of 1
, 2
and 4
.
Rearrange the category relationships for the Post
model:
The post
model is associated with categories ids of 1
and 5
.
Extending
I suggest, you always extend the Category
model to define your relationships directly. Create you own Category
model:
You publish the package config:
This is the contents of the published config file:
That is all. Now let's play for relationship query with the category.
If we did not extend the Category
model, as had to use;
License
This package is licensed under The MIT License (MIT).
All versions of laravel-categorizable with dependencies
illuminate/database Version ~5.4|~5.5
illuminate/support Version ~5.4|~5.5