/** * Applies a lock to the rows between the supplied index boundaries. * * @param int $lft * @param int $rgt * @return void */ protected function applyLockBetween($lft, $rgt) { $this->node->newQuery()->where($this->node->getLeftColumnName(), '>=', $lft)->where($this->node->getRightColumnName(), '<=', $rgt)->select($this->node->getKeyName())->lockForUpdate()->get(); }
protected function wrapInTransaction(Closure $callback) { return $this->node->getConnection()->transaction($callback); }
/** * Builds a single string for the given scope columns values. Useful for * making array keys for grouping. * * @param \AwatBayazidi\Foundation\Tree\Node $node * @return string */ protected function keyForScope($node) { return implode('-', array_map(function ($column) use($node) { $value = $node->getAttribute($column); if (is_null($value)) { return 'NULL'; } return $value; }, $node->getScopedColumns())); }
/** * Get the fully qualified value for the specified column. * * @return string */ protected function qualify($column) { return $this->node->getTable() . '.' . $column; }
/** * Return an array with the last node we could reach and its nesting level * * @param \AwatBayazidi\Foundation\Tree\Node $node * @param integer $nesting * @return array */ protected function determineDepth($node, $nesting = 0) { // Traverse back up the ancestry chain and add to the nesting level count while ($parent = $node->parent()->first()) { $nesting = $nesting + 1; $node = $parent; } return array($node, $nesting); }