minor fixes

This commit is contained in:
ludo
2024-02-23 08:35:41 +01:00
parent 3acb69abe4
commit c15a6e380f
47 changed files with 148 additions and 2458 deletions

View File

@@ -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)