From 4b947a0d64157ea083ead95d5e6ad2671d1afac6 Mon Sep 17 00:00:00 2001 From: Andras Bacsai <5845193+andrasbacsai@users.noreply.github.com> Date: Sat, 4 Oct 2025 18:02:20 +0200 Subject: [PATCH] refactor(deployment): enhance deployment data retrieval and relationships - Updated the deployments method in DeploymentsIndicator to include application environment and project relationships for better data context. - Refactored the application method in ApplicationDeploymentQueue to use Eloquent relationships instead of manual fetching, improving performance and readability. - Enhanced the deployments indicator view to display application environment and project names, providing clearer deployment context. --- app/Livewire/DeploymentsIndicator.php | 3 ++- app/Models/ApplicationDeploymentQueue.php | 6 ++---- resources/views/livewire/deployments-indicator.blade.php | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Livewire/DeploymentsIndicator.php b/app/Livewire/DeploymentsIndicator.php index 0293ad6c6..ac9cfd1c2 100644 --- a/app/Livewire/DeploymentsIndicator.php +++ b/app/Livewire/DeploymentsIndicator.php @@ -16,7 +16,8 @@ public function deployments() { $servers = Server::ownedByCurrentTeam()->get(); - return ApplicationDeploymentQueue::whereIn('status', ['in_progress', 'queued']) + return ApplicationDeploymentQueue::with(['application.environment.project']) + ->whereIn('status', ['in_progress', 'queued']) ->whereIn('server_id', $servers->pluck('id')) ->orderBy('id') ->get([ diff --git a/app/Models/ApplicationDeploymentQueue.php b/app/Models/ApplicationDeploymentQueue.php index 8df6877ab..4e8eee10f 100644 --- a/app/Models/ApplicationDeploymentQueue.php +++ b/app/Models/ApplicationDeploymentQueue.php @@ -41,11 +41,9 @@ class ApplicationDeploymentQueue extends Model { protected $guarded = []; - public function application(): Attribute + public function application() { - return Attribute::make( - get: fn () => Application::find($this->application_id), - ); + return $this->belongsTo(Application::class); } public function server(): Attribute diff --git a/resources/views/livewire/deployments-indicator.blade.php b/resources/views/livewire/deployments-indicator.blade.php index ed24249e0..7f3cc23ed 100644 --- a/resources/views/livewire/deployments-indicator.blade.php +++ b/resources/views/livewire/deployments-indicator.blade.php @@ -68,6 +68,9 @@ class="flex items-start gap-3 p-3 rounded-lg dark:bg-coolgray-200 bg-gray-50 tra {{ $deployment->application_name }}
+ {{ $deployment->application?->environment?->project?->name }} / {{ $deployment->application?->environment?->name }} +
+{{ $deployment->server_name }}
@if ($deployment->pull_request_id)