Fixes on reordering categories
This commit is contained in:
@@ -99,6 +99,11 @@ class Categories
|
||||
return "1";
|
||||
}
|
||||
|
||||
public static function moveTree($node_id, $target_id, $type)
|
||||
{
|
||||
return CategoryTrees::moveTree($node_id, $target_id, $type);
|
||||
}
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$node = CategoryTrees::create($data);
|
||||
|
||||
@@ -8,7 +8,7 @@ class CategoryTrees
|
||||
{
|
||||
public static function getTree()
|
||||
{
|
||||
$categories = app('rinvex.categories.category')->get()->toTree()->toArray();
|
||||
$categories = app('rinvex.categories.category')->orderBy('_lft','asc')->get()->toTree()->toArray();
|
||||
return self::getChildren($categories[0]['children']);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,25 @@ class CategoryTrees
|
||||
return $tree;
|
||||
}
|
||||
|
||||
public static function moveTree($node_id, $target_id, $type)
|
||||
{
|
||||
$category = self::getNode($node_id);
|
||||
$category_target = self::getNode($target_id);
|
||||
|
||||
switch ($type) {
|
||||
case 'after':
|
||||
dump("$node_id After $target_id");
|
||||
$category->afterNode($category_target);
|
||||
break;
|
||||
case 'inside':
|
||||
dump("$node_id inside $target_id");
|
||||
$category_target->appendNode($category);
|
||||
break;
|
||||
}
|
||||
$category->save();
|
||||
return "1";
|
||||
}
|
||||
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user