fix(clears-global-search-cache): refine team retrieval logic in getTeamIdForCache method

- Updated the getTeamIdForCache method to differentiate team retrieval based on the instance type, ensuring correct access to the team property or method for Server models and other types.
This commit is contained in:
Andras Bacsai
2025-09-23 15:27:47 +02:00
parent 106682b5b8
commit 82a8c42d9a

View File

@@ -66,7 +66,11 @@ trait ClearsGlobalSearchCache
{ {
// For database models, team is accessed through environment.project.team // For database models, team is accessed through environment.project.team
if (method_exists($this, 'team')) { if (method_exists($this, 'team')) {
if ($this instanceof \App\Models\Server) {
$team = $this->team; $team = $this->team;
} else {
$team = $this->team();
}
if (filled($team)) { if (filled($team)) {
return is_object($team) ? $team->id : null; return is_object($team) ? $team->id : null;
} }