mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-13 00:14:24 +00:00
Refactor default_environment method to handle projects with 0 environments
This commit is contained in:
1 parent
4869c388b2
commit
99354f0d7d
3 files changed
+9
-5
No files matched your search
@@ -116,10 +116,14 @@ class Project extends BaseModel
|
||||
public function default_environment()
|
||||
{
|
||||
$default = $this->environments()->where('name', 'production')->first();
|
||||
if (! $default) {
|
||||
$default = $this->environments()->get()->sortBy('created_at')->first();
|
||||
if ($default) {
|
||||
return $default->name;
|
||||
}
|
||||
$default = $this->environments()->get();
|
||||
if ($default->count() > 0) {
|
||||
return $default->sortBy('created_at')->first()->name;
|
||||
}
|
||||
|
||||
return $default;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user