minor fixes
This commit is contained in:
@@ -28,10 +28,10 @@ class Trees
|
||||
return $tree;
|
||||
}
|
||||
|
||||
public static function moveTree($node_id, $target_id, $type)
|
||||
public static function moveTree($node_id, $target_id, $type, $model)
|
||||
{
|
||||
$item = self::getNode($node_id);
|
||||
$item_target = self::getNode($target_id);
|
||||
$item = self::getNode($node_id, $model);
|
||||
$item_target = self::getNode($target_id, $model);
|
||||
|
||||
switch ($type) {
|
||||
case 'after':
|
||||
@@ -49,7 +49,7 @@ class Trees
|
||||
|
||||
public static function create($data, $model)
|
||||
{
|
||||
$parent = $data['parent_id'] ?? false ? self::getNode($data['parent_id']) : self::getRoot();
|
||||
$parent = $data['parent_id'] ?? false ? self::getNode($data['parent_id'], $model) : self::getRoot($model);
|
||||
$tree = $model->create(['name' => $data['name']]);
|
||||
$tree->appendToNode($parent)->save();
|
||||
|
||||
@@ -69,9 +69,9 @@ class Trees
|
||||
// return Category::destroy($id);
|
||||
}
|
||||
|
||||
public static function getRoot()
|
||||
public static function getRoot($model)
|
||||
{
|
||||
return self::getNode(1);
|
||||
return self::getNode(1, $model);
|
||||
}
|
||||
|
||||
public static function getNode($id, $model)
|
||||
|
||||
Reference in New Issue
Block a user