mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-18 01:20:31 +00:00
refactor: replace queries with cached versions for performance improvements
This commit is contained in:
@@ -30,11 +30,25 @@ class Project extends BaseModel
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
/**
|
||||
* Get query builder for projects owned by current team.
|
||||
* If you need all projects without further query chaining, use ownedByCurrentTeamCached() instead.
|
||||
*/
|
||||
public static function ownedByCurrentTeam()
|
||||
{
|
||||
return Project::whereTeamId(currentTeam()->id)->orderByRaw('LOWER(name)');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all projects owned by current team (cached for request duration).
|
||||
*/
|
||||
public static function ownedByCurrentTeamCached()
|
||||
{
|
||||
return once(function () {
|
||||
return Project::ownedByCurrentTeam()->get();
|
||||
});
|
||||
}
|
||||
|
||||
protected static function booted()
|
||||
{
|
||||
static::created(function ($project) {
|
||||
|
||||
Reference in New Issue
Block a user