Skip to content

Commit

Permalink
small tweaks for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
franzose committed Oct 5, 2020
1 parent e8c4035 commit 66a7af5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/Models/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function setParentIdAttribute($value)
}

$parentId = $this->getParentIdColumn();
$this->previousParentId = isset($this->original[$parentId]) ? $this->original[$parentId] : null;
$this->previousParentId = $this->original[$parentId] ?? null;
$this->attributes[$parentId] = $value;
}

Expand Down Expand Up @@ -212,7 +212,7 @@ public function setPositionAttribute($value)
}

$position = $this->getPositionColumn();
$this->previousPosition = isset($this->original[$position]) ? $this->original[$position] : null;
$this->previousPosition = $this->original[$position] ?? null;
$this->attributes[$position] = max(0, (int) $value);
}

Expand Down Expand Up @@ -298,7 +298,7 @@ public static function boot()
$entity->previousPosition = null;

$descendant = $entity->getKey();
$ancestor = isset($entity->parent_id) ? $entity->parent_id : $descendant;
$ancestor = $entity->parent_id ?? $descendant;

$entity->closure->insertNode($ancestor, $descendant);
});
Expand Down Expand Up @@ -883,7 +883,7 @@ public function getChildrenRange($from, $to = null, array $columns = ['*'])
public function addChild(EntityInterface $child, $position = null, $returnChild = false)
{
if ($this->exists) {
$position = $position !== null ? $position : $this->getLatestChildPosition();
$position = $position ?? $this->getLatestChildPosition();

$child->moveTo($position, $this);
}
Expand Down Expand Up @@ -1596,7 +1596,7 @@ private function buildSiblingQuery(Builder $builder, $id, callable $positionCall
public function addSibling(EntityInterface $sibling, $position = null, $returnSibling = false)
{
if ($this->exists) {
$position = $position === null ? static::getLatestPosition($this) : $position;
$position = $position ?? static::getLatestPosition($this);

$sibling->moveTo($position, $this->parent_id);

Expand All @@ -1623,7 +1623,7 @@ public function addSiblings(array $siblings, $from = null)
return $this;
}

$from = $from === null ? static::getLatestPosition($this) : $from;
$from = $from ?? static::getLatestPosition($this);

$this->transactional(function () use ($siblings, &$from) {
foreach ($siblings as $sibling) {
Expand Down Expand Up @@ -1876,7 +1876,7 @@ public function deleteSubtree($withSelf = false, $forceDelete = false)
* @param array $models
* @return \Illuminate\Database\Eloquent\Collection
*/
public function newCollection(array $models = array())
public function newCollection(array $models = [])
{
return new Collection($models);
}
Expand Down

0 comments on commit 66a7af5

Please sign in to comment.