New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

unisharp/categorizable

categorize model
14,876 3
Install
composer require unisharp/categorizable
Latest Version:1.3.2
PHP:^7.0
Laravel:5 · 6
License:MIT
Last Updated:Nov 21, 2019
Links: GitHub  ·  Packagist
Maintainer: FreedomKnight

Categorizable

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

It's a package to let you cagorize anything

Install

Via Composer

$ composer require unisharp/categorizable

Usage

use UniSharp\Category\Categorizable;

class Post extends Model {
    use Categorizable;
}

categorize

You can categorize by id, name or mixed array and id won't add duplicate category

$post->categorize(1); // by category id, it will do nothing if it can't find this category

$post->categorize("News"); // by category name and it will create new one if it can't find category

$post->categorize([1, "news"]); // You can use array

$post->categorize(1, "news"); // it's same as using array

uncategorize

It will remove category just like categorize

$post->uncategorize(1);

$post->uncategorize("News");

$post->uncategorize([1, "news"]);

$post->uncategorize(1, "news");

decategorize

remove all category

$post->decategorize();

recategorize

it will add category after clean all binding categories

same as $post->decategorize()->categorize(....)

$post->recategorize(1);

$post->recategorize("News");

$post->recategorize([1, "news"]);

$post->recategorize(1, "news");

hasCategories

You can find model which has specify categories it also search all children category

Post::hasCategories('News', 1)->get();

hasStrictCategories

It's same as hasCategories but just find category which you specify

Post::hasStrictCategories('News', 1)->get();

You can find model which has specify categories it also search all children category

Post::hasCategories('News', 1)->get();

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email xing1615@gmail.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

unisharp/buyable

let laravel model buyable

2,084 3
unisharp/cart

let buyable item can add to cart

1,739 1
vergil-lai/node-categories

Node categories model and observer for laravel 5

574 22
vanilo/category

Vanilo Category Module

247,006 9

Version History

Version Released PHP Laravel License
1.3.2 ^7.0 >=5.5.0 MIT
1.3.1 ^7.0 >=5.5.0 MIT
1.3.0 ^7.0 ~5.5.0 || ~5.6.0 MIT
1.2.2 ^7.0 ~5.5.0 MIT
1.2.1 ^7.0 ~5.5.0 MIT