This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// everything's creating fine. Positions and closure table, all's fine. | |
$Test = Test::create(array()); | |
$child1 = $Test->appendChild(Test::make(), 0, true); | |
$child2 = $Test->appendChild(Test::make(), 1, true); | |
$child3 = $Test->appendChild(Test::make(), 2, true); | |
$child4 = $Test->appendChild(Test::make(), 3, true); | |
// this returns ids of $Test, $child1, $child2 and $child3... | |
dd($child4->prevSiblings()->lists('id')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function make(array $attributes = array()) | |
{ | |
$model = new static(); | |
// Workaround to set the position | |
if ( ! isset($attributes[static::POSITION])) | |
{ | |
// We set depth to 0 because newly created model | |
// via 'create' method has no default closure table | |
// attributes and is inserted as a root node |
NewerOlder