{"id":15825319,"url":"https://github.com/code-axion/nestifyx","last_synced_at":"2026-04-12T13:51:10.298Z","repository":{"id":224205907,"uuid":"757490259","full_name":"CODE-AXION/NestifyX","owner":"CODE-AXION","description":"A Laravel Package for Effortless Drag-and-drop categories/subcategories reordering and sets of recursive methods to play with nested structures","archived":false,"fork":false,"pushed_at":"2024-02-25T17:41:04.000Z","size":53,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-26T00:25:25.655Z","etag":null,"topics":["alpinejs","drag-and-drop","javascript","jquery","jstree","laravel","laravel-framework","laravel-package","package","php","plugin","recursion","reordering","tailwindcss","ui"],"latest_commit_sha":null,"homepage":"https://youtu.be/XwGvh_4aXvA","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/CODE-AXION.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-14T15:50:39.000Z","updated_at":"2024-02-25T17:40:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"3a983adc-e248-441a-b515-0ddf2e6931ed","html_url":"https://github.com/CODE-AXION/NestifyX","commit_stats":null,"previous_names":["code-axion/nestifyx"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CODE-AXION%2FNestifyX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CODE-AXION%2FNestifyX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CODE-AXION%2FNestifyX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CODE-AXION%2FNestifyX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CODE-AXION","download_url":"https://codeload.github.com/CODE-AXION/NestifyX/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246620099,"owners_count":20806715,"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":["alpinejs","drag-and-drop","javascript","jquery","jstree","laravel","laravel-framework","laravel-package","package","php","plugin","recursion","reordering","tailwindcss","ui"],"created_at":"2024-10-05T09:07:42.866Z","updated_at":"2026-04-12T13:51:10.256Z","avatar_url":"https://github.com/CODE-AXION.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# NestifyX Laravel Package \n\n\u003ch2\u003e\n  \u003cimg  src=\"https://github.com/CODE-AXION/NestifyX/assets/97381867/13f078a2-a179-4b06-8a2b-813a2490fcec\" /\u003e\n\u003c/h2\u003e\n \n## Overview\n\n\nThe NestifyX Laravel package provides features for managing categories and manipulate nested elements within your application using recursive methods.\n\u003e Organize Your Categories with Ease.\n\u003cbr\u003e\n\u003ch2\u003e\n    \u003cimg  src=\"https://github.com/CODE-AXION/NestifyX/assets/97381867/c8e1f213-9b9f-4e8c-ad23-a88aadc204e8\" /\u003e\n\u003c/h2\u003e\n\n## Features\n1. **Category Tree Management:** This Module includes Category Management with the Ability of changing its position using drag and drop feature, you just have to include a button component and that's it .\n   \n2. **Recursion Methods:** This Module includes various methods to play with recursions, like generating tree, fetch Children/Parent ids, generate breadcrumbs, show tree view in dropdown etc... \n\n3. **Performance:** Will do all your work in a single query.\n\n#### Required Dependencies To Run Js Tree pop up\n\u003eAlpineJs, Jquery, Jstree \n\n\u003ca href=\"https://youtu.be/XwGvh_4aXvA\"\u003eDemo Video\u003c/a\u003e\n\n## Installation\nTo utilize the NestifyX package in your application, follow these steps:\n\n1. **Installation**: Install the NestifyX package via Composer:\n \n ```bash\n   composer require codeaxion/nestifyx\n ```\n\n2. Add Your Required Dependencies via CDN (without these dependencies jstree wont work)\n\n```js\n  //only optional if you have already have alpine js and tailwindcss package installed\n  \u003cscript src=\"//unpkg.com/alpinejs\" defer\u003e\u003c/script\u003e \n  \u003cscript src=\"https://cdn.tailwindcss.com\"\u003e\u003c/script\u003e\n\n  //jquery in header\n  \u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js\" integrity=\"sha512-aVKKRRi/Q/YV+4mjoKBsE4x3H+BkegoM/em46NNlCqNTmUYADjBbeNefNxYV7giUp0VxICtqdrbqU7iVaeZNXA==\" crossorigin=\"anonymous\" referrerpolicy=\"no-referrer\"\u003e\u003c/script\u003e\n\n  //jstree scripts and css (add styles in header and scripts in body)\n  \u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/jstree.min.js\"\u003e\u003c/script\u003e\n  \u003clink rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/jstree/3.2.1/themes/default/style.min.css\" /\u003e\n\n\n```\n3. Run necessary Migration \n\u003e Will add position column in your categories table for ordering\n```php\n  php artisan migrate;\n```\n\n4. Integration: Include the Nestify Facade\n\n```php\n  use CodeAxion\\NestifyX\\Facades\\NestifyX;\n```\nThats's it Your setup is over\n\n## Optional \n\n5. (Optional) Publish config file if you have different table name\n\n```\nphp artisan vendor:publish --provider=\"CodeAxion\\NestifyX\\NestifyXServiceProvider\" --tag=\"config\"\n\n```\n\n6. (Optional) Publish migration if you want\n\n```\nphp artisan vendor:publish --provider=\"CodeAxion\\NestifyX\\NestifyXServiceProvider\" --tag=\"migrations\"\n\n```\n\n\n\n\n## Usage\n\n### Add Category Module Slider\n\u003e After adding this blade component click on the button named category tree to open category module slider  \n```html\n  \u003cx-nestifyx::category-tree-alpine /\u003e\n```\n\n\n#### Convert Normal Eloquent Collection/Array To Nested Tree\n\n  ```php\n   use CodeAxion\\NestifyX\\Facades\\NestifyX;\n\n   $categories = Category::orderByRaw('-position DESC')-\u003eget();\n\n   $categories = NestifyX::nestTree($categories);\n  ```\n\n#### Sort Children without converting it to tree\n\n```php\n  use CodeAxion\\NestifyX\\Facades\\NestifyX;\n\n  $categories = Category::orderByRaw('-position DESC')-\u003eget(); //Sort by children with it's position (RECOMMENDED after sorting is done by jstree)\n  //OR\n  $categories = Category::get() //Sort by only children;\n\n  //will return original database collection \n  $categories = NestifyX::setIndent('|--')-\u003esortChildren($categories); //fetch all categories and subcategories\n  //OR\n  $categories = NestifyX::setIndent('|--')-\u003esortChildren($categories,5) //Pass different category id if you want their children of (refer to 2nd example)\n\n  // In view\n  @foreach($categories as $category)\n  \u003cdiv\u003e {{$category-\u003eindent}} {{$category-\u003ename}} \u003c/div\u003e\n  @endforeach\n\n  //Will result\n  /** \n  Electronics\n  |-- Mobiles\n  |-- |-- All Mobiles\n  |-- Headphones\n  |-- |-- All Headphones\n  |-- Gaming\n  |-- |-- Gaming Laptops\n  |-- |-- Business Laptops\n  |-- Laptops\n  |-- |-- All Laptops\n  |-- |-- Apple Laptops\n  |-- |-- Microsoft Laptops\n  */\n```\n\n#### Flatten Children (- useful for dropdowns)\n\n```php\n    use CodeAxion\\NestifyX\\Facades\\NestifyX;\n\n    $categories = \\App\\Models\\Category::orderByRaw('-position DESC')-\u003eget();\n\n    //fetch all categories and subcategories (CASE 1)\n    $categories = NestifyX::setIndent('|--')-\u003elistsFlattened($categories); \n\n    //OR\n    //pass different category id if you want their children of (CASE 2)\n    $categories = NestifyX::setIndent('|--')-\u003elistsFlattened($categories,5);\n    //OR\n    ////if your column name is different (default will be name)\n    $categories = NestifyX::setIndent('|--')-\u003esetColumn('title')-\u003elistsFlattened($categories); \n\n    dd($categories);\n\n    //Result (CASE 1):\n    /**\n      #items: array:7 [▼\n        4 =\u003e \"Electronics\"\n        5 =\u003e \"|--Laptops\"\n        9 =\u003e \"|--|--All Laptops\"\n        7 =\u003e \"|--Mobiles\"\n        10 =\u003e \"|--|--All Mobiles\"\n        8 =\u003e \"|--Headphones\"\n        11 =\u003e \"|--|--All Headphones\"\n      ]\n    */\n\n    //Result (CASE 2):\n    /**\n      #items: array:7 [▼\n        5 =\u003e \"Laptops\"\n        9 =\u003e \"|-- All Laptops\"\n      ]\n    */\n\n\n```\n```html\n\n  \u003c!-- In view --\u003e\n \u003cselect class=\"border-gray-400\" name=\"\" id=\"\"\u003e\n      @foreach ($categories as $id =\u003e $name)\n      \u003coption value=\"{{$id}}\"\u003e {{$name}} \u003c/option\u003e\n      @endforeach\n  \u003c/select\u003e\n```\n\n#### Generate breadcrumbs for all categories\n\n```php\n    $categories = \\App\\Models\\Category::orderByRaw('-position DESC')-\u003eget();\n \n    $categories = NestifyX::setIndent(' \\ ')-\u003egenerateBreadCrumbs($categories);\n\n    //will return flattened Result:\n    \n    array:7 [▼ // routes\\web.php:27\n      4 =\u003e \"Electronics\"\n      5 =\u003e \"Electronics \\ Laptops\"\n      9 =\u003e \"Electronics \\ Laptops \\ All Laptops\"\n      7 =\u003e \"Electronics \\ Mobiles\"\n      10 =\u003e \"Electronics \\ Mobiles \\ All Mobiles\"\n      8 =\u003e \"Electronics \\ Headphones\"\n      11 =\u003e \"Electronics \\ Headphones \\ All Headphones\"\n    ]\n```\n\n\n#### Generate current breadcrumbs \n```php\n\n    $categories = Category::get();\n\n    $categories = NestifyX::generateCurrentBreadCrumbs($categories,5); //2nd param: child id \n\n    array:2 [▼ \n      4 =\u003e array:2 [▼\n        \"name\" =\u003e \"Electronics\"\n        \"category\" =\u003e array:8 [▼\n          \"id\" =\u003e 4\n          \"name\" =\u003e \"Electronics\"\n          \"parent_id\" =\u003e null\n          \"created_at\" =\u003e \"2024-02-18T13:37:52.000000Z\"\n          \"updated_at\" =\u003e \"2024-02-22T16:40:00.000000Z\"\n        ]\n      ]\n      5 =\u003e array:2 [▼\n        \"name\" =\u003e \"Laptops\"\n        \"category\" =\u003e array:8 [▼\n          \"id\" =\u003e 5\n          \"name\" =\u003e \"Laptops\"\n          \"parent_id\" =\u003e 4\n          \"created_at\" =\u003e \"2024-02-18T13:43:26.000000Z\"\n          \"updated_at\" =\u003e \"2024-02-22T16:40:00.000000Z\"\n        ]\n      ]\n    ]\n```\n\n```html\n//in view\n\n  \u003cdiv class=\"flex gap-2\"\u003e\n      \u003ca href=\"/\"\u003e Home \u003c/a\u003e \n      @foreach ($categories as $category)\n      \u003ca href=\"{{route('shop-page',$category['category']['id'])}}\"\u003e \\ {{$category['name']}} \u003c/a\u003e\n      @endforeach\n  \u003c/div\u003e\n        \n```\n\n\n#### Get all parent ids of a child category\n```php\n\n    $categories = Category::get();\n   \n    $categories = NestifyX::collectParentIds($categories,11);\n\n```\n\n#### Get all child ids of a parent category\n```php\n\n    $categories = Category::get();\n\n    $categories = NestifyX::collectChildIds($categories,4);\n\n```\n\n\n\n### Upcoming Feature\n\u003e - Add Nestable2 plugin feature in Categories \u003cbr\u003e\n\u003e - Remove Alpine js dependency\n\u003e - Add support for bootstrap\n\n\u003cbr\u003e\nNew features suggestions are always welcome\n\n### Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n\u003c!-- ### Security\n\nIf you discover any security related issues, please email codeaxion77@gmail.com instead of using the issue tracker. --\u003e\n\n## Credits\n\n-   [Code Axion](https://github.com/code-axion)\n\u003c!-- -   [All Contributors](../../contributors) --\u003e\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-axion%2Fnestifyx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-axion%2Fnestifyx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-axion%2Fnestifyx/lists"}