2023-11-21 14:31:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project\Application;
|
2023-11-21 14:31:46 +00:00
|
|
|
|
|
|
|
|
use App\Models\Application;
|
|
|
|
|
use App\Models\Server;
|
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
|
|
class Configuration extends Component
|
|
|
|
|
{
|
|
|
|
|
public Application $application;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-11-21 14:31:46 +00:00
|
|
|
public $servers;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-03-01 09:36:32 +00:00
|
|
|
protected $listeners = ['buildPackUpdated' => '$refresh'];
|
2024-01-10 10:07:53 +00:00
|
|
|
|
2023-11-21 14:31:46 +00:00
|
|
|
public function mount()
|
|
|
|
|
{
|
2024-12-02 12:12:25 +00:00
|
|
|
$this->application = Application::query()
|
|
|
|
|
->whereHas('environment.project', function ($query) {
|
|
|
|
|
$query->where('team_id', currentTeam()->id)
|
|
|
|
|
->where('uuid', request()->route('project_uuid'));
|
|
|
|
|
})
|
|
|
|
|
->whereHas('environment', function ($query) {
|
|
|
|
|
$query->where('name', request()->route('environment_name'));
|
|
|
|
|
})
|
2024-11-27 07:07:54 +00:00
|
|
|
->where('uuid', request()->route('application_uuid'))
|
2024-12-02 12:12:25 +00:00
|
|
|
->with(['destination' => function ($query) {
|
|
|
|
|
$query->select('id', 'server_id');
|
|
|
|
|
}])
|
2024-11-27 07:07:54 +00:00
|
|
|
->firstOrFail();
|
|
|
|
|
|
2024-12-02 12:12:25 +00:00
|
|
|
if ($this->application->destination && $this->application->destination->server_id) {
|
2024-11-27 07:07:54 +00:00
|
|
|
$this->servers = Server::ownedByCurrentTeam()
|
|
|
|
|
->select('id', 'name')
|
2024-12-02 12:12:25 +00:00
|
|
|
->where('id', '!=', $this->application->destination->server_id)
|
2024-11-27 07:07:54 +00:00
|
|
|
->get();
|
|
|
|
|
} else {
|
|
|
|
|
$this->servers = collect();
|
|
|
|
|
}
|
2023-11-21 14:31:46 +00:00
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-11-21 14:31:46 +00:00
|
|
|
public function render()
|
|
|
|
|
{
|
|
|
|
|
return view('livewire.project.application.configuration');
|
|
|
|
|
}
|
|
|
|
|
}
|