Skip to content

Commit 93a595b

Browse files
committed
relation
1 parent 9085a7d commit 93a595b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/lib/Models/Traits/RelateToSpace.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
trait RelateToSpace {
66
protected ?string $space_key;
7+
78
public function getSpaceKey (): ?string {
89
return $this->space_key;
910
}
@@ -12,9 +13,12 @@ public function setSpaceKey ( $key ) {
1213
$this->space_key = $key;
1314
}
1415

15-
public function relation($parent=null):void{
16-
parent::relation($parent);
16+
public function relation ( $parent = null ): void {
17+
parent::relation( $parent );
1718
$this->space_key = null;
18-
$this->space_key = $this->spaceKey ?? $parent?->getSpaceKey() ?? $parent?->spaceKey ?? null;
19+
$this->space_key = $parent?->spaceKey ?? null;
20+
if ( $parent && method_exists( $parent, 'getSpaceKey' ) ) {
21+
$this->space_key = $parent->getSpaceKey() ?? null;
22+
}
1923
}
2024
}

0 commit comments

Comments
 (0)