Refactor loadData method in Destination.php
This commit is contained in:
parent
50f43f9396
commit
6a00d8c88c
@ -19,6 +19,7 @@ public function getListeners()
|
||||
$teamId = auth()->user()->currentTeam()->id;
|
||||
return [
|
||||
"echo-private:team.{$teamId},ApplicationStatusChanged" => 'loadData',
|
||||
"loadData",
|
||||
];
|
||||
}
|
||||
public function mount()
|
||||
@ -40,6 +41,9 @@ public function loadData()
|
||||
$this->networks = $this->networks->reject(function ($network) {
|
||||
return $this->resource->destination->server->id == $network->server->id;
|
||||
});
|
||||
$this->networks = $this->networks->reject(function ($network) {
|
||||
return $this->resource->additional_servers->pluck('id')->contains($network->server->id);
|
||||
});
|
||||
}
|
||||
public function redeploy(int $network_id, int $server_id)
|
||||
{
|
||||
@ -68,8 +72,8 @@ public function addServer(int $network_id, int $server_id)
|
||||
{
|
||||
$this->resource->additional_networks()->attach($network_id, ['server_id' => $server_id]);
|
||||
$this->resource->load(['additional_networks']);
|
||||
$this->dispatch('loadData');
|
||||
ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id'));
|
||||
$this->loadData();
|
||||
}
|
||||
public function removeServer(int $network_id, int $server_id)
|
||||
{
|
||||
@ -81,7 +85,7 @@ public function removeServer(int $network_id, int $server_id)
|
||||
StopApplicationOneServer::run($this->resource, $server);
|
||||
$this->resource->additional_networks()->detach($network_id, ['server_id' => $server_id]);
|
||||
$this->resource->load(['additional_networks']);
|
||||
$this->dispatch('loadData');
|
||||
ApplicationStatusChanged::dispatch(data_get($this->resource, 'environment.project.team.id'));
|
||||
$this->loadData();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user