refactor(global-search, environment): streamline environment retrieval with new query method

- Replaced the inline query for fetching environments in GlobalSearch with a new static method `ownedByCurrentTeam` in the Environment model, enhancing code readability and maintainability.
- This change simplifies the logic for retrieving environments associated with the current team, promoting better organization of query logic within the model.
This commit is contained in:
Andras Bacsai
2025-10-08 19:58:36 +02:00
parent c548013e2d
commit b803a137f6
2 changed files with 6 additions and 4 deletions

View File

@@ -35,6 +35,11 @@ class Environment extends BaseModel
});
}
public static function ownedByCurrentTeam()
{
return Environment::whereRelation('project.team', 'id', currentTeam()->id)->orderBy('name');
}
public function isEmpty()
{
return $this->applications()->count() == 0 &&