Baum\Node::parent PHP Метод

parent() публичный Метод

Parent relation (self-referential) 1-1.
public parent ( ) : BelongsTo
Результат Illuminate\Database\Eloquent\Relations\BelongsTo
    public function parent()
    {
        return $this->belongsTo(get_class($this), $this->getParentColumnName());
    }

Usage Example

Пример #1
0
 /**
  * Return an array with the last node we could reach and its nesting level.
  *
  * @param   \Baum\Node $node
  * @param   int $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 [$node, $nesting];
 }