Skip to content

Commit

Permalink
Adds getMultisiteKey helper to match getKey
Browse files Browse the repository at this point in the history
  • Loading branch information
daftspunk committed Apr 25, 2024
1 parent 1e5308b commit ba495f9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Database/Traits/Multisite.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,18 @@ public function propagateToSite($siteId, $otherModel = null)
return $otherModel;
}

/**
* getMultisiteKey returns the root key if multisite is used
*/
public function getMultisiteKey()
{
if (!$this->isMultisiteEnabled()) {
return $this->getKey();
}

return $this->site_root_id ?: $this->getKey();
}

/**
* isMultisiteEnabled allows for programmatic toggling
* @return bool
Expand Down

0 comments on commit ba495f9

Please sign in to comment.