Esempio n. 1
0
 /**
  * After mode was saved we're building node path
  *
  * @param Tree $model
  */
 public function saved(Tree $model)
 {
     if ($model->{$model->getTreeColumn('path')} === '') {
         // If we just save() new node
         $model->{$model->getTreeColumn('path')} = $model->getKey() . '/';
         DB::table($model->getTable())->where($model->getKeyName(), '=', $model->getKey())->update(array($model->getTreeColumn('path') => $model->{$model->getTreeColumn('path')}));
     }
 }
Esempio n. 2
0
 /**
  * Check if node is sibling for roots in collection
  *
  * @param Tree       $node  Tree node
  * @param Collection $roots Collection of roots
  *
  * @return bool
  */
 private function siblingOfRoot(Tree $node, Collection $roots)
 {
     return (bool) $roots->filter(function ($item) use($node) {
         return $node->isSibling($item);
     })->first();
 }