1. Go to this page and download the library: Download easydot/nested-categories library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
easydot / nested-categories example snippets
use Easydot\NestedCategory\NestableCategory;
class Category extends Model
{
use NestableCategory;
....
}
class Category extends Model
{
....
protected $fillable = ['path'];
....
}
#OR
class Category extends Model
{
....
protected $guarded = [];
....
}
use Easydot\NestedCategory\NestableCategory;
use Easydot\NestedCategory\AutoRebuildNested;
class Category extends Model
{
use NestableCategory, AutoRebuildNested;
....
}
#The same
$category->save();
$category->rebuild();
$category->update();
$category->rebuild();
$category->delete();
$category->rebuild();