2017 © Pedro Peláez
 

library categorizable

categorize model

image

unisharp/categorizable

categorize model

  • Friday, June 29, 2018
  • by youchenlee
  • Repository
  • 9 Watchers
  • 0 Stars
  • 1,511 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 39 % Grown

The README.md

Categorizable

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

It's a package to let you cagorize anything, (*2)

Install

Via Composer, (*3)

``` bash $ composer require unisharp/categorizable, (*4)


## Usage ``` php 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, (*5)

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

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

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

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


### uncategorize It will remove category just like categorize ``` php $post->uncategorize(1); $post->uncategorize("News"); $post->uncategorize([1, "news"]); $post->uncategorize(1, "news");

decategorize

remove all category, (*10)

$post->decategorize();

recategorize

it will add category after clean all binding categories, (*11)

same as $post->decategorize()->categorize(....), (*12)

$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, (*13)

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

hasStrictCategories

It's same as hasCategories but just find category which you specify, (*14)

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

You can find model which has specify categories it also search all children category, (*15)

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

Change log

Please see CHANGELOG for more information on what has changed recently., (*16)

Testing

bash $ composer test, (*17)

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details., (*18)

Security

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

Credits

License

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

The Versions