PHPackages                             unisharp/categorizable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. unisharp/categorizable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

unisharp/categorizable
======================

categorize model

1.3.2(6y ago)314.7k1MITPHPPHP ^7.0CI failing

Since Feb 2Pushed 6y ago12 watchersCompare

[ Source](https://github.com/UniSharp/categorizable)[ Packagist](https://packagist.org/packages/unisharp/categorizable)[ Docs](https://github.com/UniSharp/category)[ RSS](/packages/unisharp-categorizable/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (12)Versions (14)Used By (0)

Categorizable
=============

[](#categorizable)

[![Latest Version on Packagist](https://camo.githubusercontent.com/e5fb9131d2bc0ef80f1502d57d68f26df739b70a8b35841c048c472320805aa0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f556e6953686172702f63617465676f72697a61626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/unisharp/categorizable)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/fdd2674bc477b540c1d3211fc83d3093e2426e6dd3148cb9530726d7c1483474/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f556e6953686172702f63617465676f72697a61626c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/UniSharp/categorizable)[![Coverage Status](https://camo.githubusercontent.com/6372eef16c1526a5283e183cdd6de89758d50a6d18064b21450a2d1bfd5b0939/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f556e6953686172702f63617465676f72697a61626c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/UniSharp/categorizable/code-structure)[![Quality Score](https://camo.githubusercontent.com/724d0ef0e31396d002a4b02d9b616ede617ae83c531881c71e062049bf1bf077/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f556e6953686172702f63617465676f72697a61626c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/UniSharp/categorizable)[![Total Downloads](https://camo.githubusercontent.com/56168d1a5502a5d22d85d30b468e893f87487689c8755d0a4c5a3241a95ec46b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f556e6953686172702f63617465676f72697a61626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/UniSharp/categorizable)

It's a package to let you cagorize anything

Install
-------

[](#install)

Via Composer

```
$ composer require unisharp/categorizable
```

Usage
-----

[](#usage)

```
use UniSharp\Category\Categorizable;

class Post extends Model {
    use Categorizable;
}
```

### categorize

[](#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

[](#uncategorize)

It will remove category just like categorize

```
$post->uncategorize(1);

$post->uncategorize("News");

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

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

### decategorize

[](#decategorize)

remove all category

```
$post->decategorize();
```

### recategorize

[](#recategorize)

it will add category after clean all binding categories

same as $post-&gt;decategorize()-&gt;categorize(....)

```
$post->recategorize(1);

$post->recategorize("News");

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

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

### hasCategories

[](#hascategories)

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

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

### hasStrictCategories

[](#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
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Xing](https://github.com/UniSharp)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 63.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~54 days

Recently: every ~128 days

Total

13

Last Release

2406d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1203922?v=4)[FreedomKnight](/maintainers/FreedomKnight)[@FreedomKnight](https://github.com/FreedomKnight)

![](https://avatars.githubusercontent.com/u/181350?v=4)[Youchen Lee (isacl)](/maintainers/youchenlee)[@youchenlee](https://github.com/youchenlee)

---

Top Contributors

[![Nehemis1615](https://avatars.githubusercontent.com/u/20162812?v=4)](https://github.com/Nehemis1615 "Nehemis1615 (7 commits)")[![EcoinTest](https://avatars.githubusercontent.com/u/153815470?v=4)](https://github.com/EcoinTest "EcoinTest (2 commits)")[![youchenlee](https://avatars.githubusercontent.com/u/181350?v=4)](https://github.com/youchenlee "youchenlee (2 commits)")

---

Tags

categoryUniSharp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/unisharp-categorizable/health.svg)

```
[![Health](https://phpackages.com/badges/unisharp-categorizable/health.svg)](https://phpackages.com/packages/unisharp-categorizable)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[api-platform/laravel

API Platform support for Laravel

59156.3k11](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
