diff --git a/app/Models/Project.php b/app/Models/Project.php index 1f39aa725..b7d34e876 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -116,10 +116,14 @@ public function databases() 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; } } diff --git a/resources/views/livewire/dashboard.blade.php b/resources/views/livewire/dashboard.blade.php index c1dd375ff..a6eb231d4 100644 --- a/resources/views/livewire/dashboard.blade.php +++ b/resources/views/livewire/dashboard.blade.php @@ -23,7 +23,7 @@