Content-Length: 256681 | pFad | http://github.com/efureev/laravel-trees/commit/f741e68885d3508f94582e4d871e0b57b94b85a2

8C optimize `treeValue` · efureev/laravel-trees@f741e68 · GitHub
Skip to content

Commit

Permalink
optimize treeValue
Browse files Browse the repository at this point in the history
  • Loading branch information
Fureev Eugene committed Jun 6, 2024
1 parent c7c876f commit f741e68
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/UseConfigShorter.php
Original file line number Diff line number Diff line change
@@ -56,7 +56,9 @@ public function treeAttribute(): ?Attribute

public function treeValue(): int|string|null
{
return $this->treeAttribute() !== null ? $this->getAttributeValue((string)$this->treeAttribute()) : null;
return $this->treeAttribute() !== null
? $this->attributes[(string)$this->treeAttribute()] ?? null
: null;
}

protected function isSoftDelete(): bool
7 changes: 3 additions & 4 deletions src/UseNestedSet.php
Original file line number Diff line number Diff line change
@@ -130,7 +130,7 @@ public function beforeInsert(): void
throw new UniqueRootException($exist);
}

$this->validateAndSetTreeID();
$this->validateAndSetTreeId();

$this->setAttribute((string)$this->leftAttribute(), 1);
$this->setAttribute((string)$this->rightAttribute(), 2);
@@ -432,10 +432,9 @@ public function getDirty(): array
return $dirty;
}

protected function validateAndSetTreeID(): void
protected function validateAndSetTreeId(): void
{
// if (!$this->isMulti() || $this->treeValue() !== null) {
if (!$this->isMulti()) {
if (!$this->isMulti() || $this->treeValue() !== null) {
return;
}

0 comments on commit f741e68

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/efureev/laravel-trees/commit/f741e68885d3508f94582e4d871e0b57b94b85a2

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy