Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
`$page = Page::make();` instead of `$page = new Page()`; Then we can set proper position...
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
$model->hidden[static::DEPTH] = 0;
$attributes[static::POSITION] = $model->guessPositionOnCreate();
return $model;
* Save a new model and return the instance.
* @param array $attributes
* @return Entity|static
public static function create(array $attributes)
$model = static::make($attributes);
return $model;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment