{"id":19706716,"url":"https://github.com/unisharp/categorizable","last_synced_at":"2025-06-20T06:35:35.046Z","repository":{"id":57075537,"uuid":"119648549","full_name":"UniSharp/categorizable","owner":"UniSharp","description":null,"archived":false,"fork":false,"pushed_at":"2019-11-21T09:03:54.000Z","size":64,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-14T04:54:43.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UniSharp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-31T07:04:46.000Z","updated_at":"2023-09-15T18:37:45.000Z","dependencies_parsed_at":"2022-08-24T14:55:44.193Z","dependency_job_id":null,"html_url":"https://github.com/UniSharp/categorizable","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fcategorizable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fcategorizable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fcategorizable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fcategorizable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UniSharp","download_url":"https://codeload.github.com/UniSharp/categorizable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251540542,"owners_count":21605927,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T21:36:40.990Z","updated_at":"2025-04-29T16:33:32.848Z","avatar_url":"https://github.com/UniSharp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Categorizable \n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nIt's a package to let you cagorize anything\n\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require unisharp/categorizable\n```\n\n## Usage\n\n``` php\nuse UniSharp\\Category\\Categorizable;\n\nclass Post extends Model {\n    use Categorizable;\n}\n```\n\n### categorize\n\nYou can categorize by id, name or mixed array and id won't add duplicate category\n\n``` php\n$post-\u003ecategorize(1); // by category id, it will do nothing if it can't find this category\n\n$post-\u003ecategorize(\"News\"); // by category name and it will create new one if it can't find category\n\n$post-\u003ecategorize([1, \"news\"]); // You can use array\n\n$post-\u003ecategorize(1, \"news\"); // it's same as using array\n\n```\n\n### uncategorize\n\nIt will remove category just like categorize\n\n``` php\n$post-\u003euncategorize(1);\n\n$post-\u003euncategorize(\"News\");\n\n$post-\u003euncategorize([1, \"news\"]);\n\n$post-\u003euncategorize(1, \"news\");\n\n```\n\n### decategorize\n\nremove all category\n\n```php\n$post-\u003edecategorize();\n\n```\n\n### recategorize\n\nit will add category after clean all binding categories\n\nsame as $post-\u003edecategorize()-\u003ecategorize(....)\n\n```php\n$post-\u003erecategorize(1);\n\n$post-\u003erecategorize(\"News\");\n\n$post-\u003erecategorize([1, \"news\"]);\n\n$post-\u003erecategorize(1, \"news\");\n\n```\n\n### hasCategories\n\nYou can find model which has specify categories\nit also search all children category \n\n```php\nPost::hasCategories('News', 1)-\u003eget();\n```\n\n### hasStrictCategories\n\nIt's same as hasCategories but just find category which you specify\n\n```php\nPost::hasStrictCategories('News', 1)-\u003eget();\n```\n\nYou can find model which has specify categories\nit also search all children category \n\n```php\nPost::hasCategories('News', 1)-\u003eget();\n```\n\n\n## Change log\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\n## Security\n\nIf you discover any security related issues, please email xing1615@gmail.com instead of using the issue tracker.\n\n## Credits\n\n- [Xing][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/UniSharp/categorizable.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/UniSharp/categorizable/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/UniSharp/categorizable.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/UniSharp/categorizable.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/UniSharp/categorizable.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/unisharp/categorizable\n[link-travis]: https://travis-ci.org/UniSharp/categorizable\n[link-scrutinizer]: https://scrutinizer-ci.com/g/UniSharp/categorizable/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/UniSharp/categorizable\n[link-downloads]: https://packagist.org/packages/UniSharp/categorizable\n[link-author]: https://github.com/UniSharp\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Fcategorizable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funisharp%2Fcategorizable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Fcategorizable/lists"}