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;
|
|
|
|
public $servers;
|
2024-01-10 10:07:53 +00:00
|
|
|
protected $listeners = ['build_pack_updated' => '$refresh'];
|
|
|
|
|
2023-11-21 14:31:46 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
$project = currentTeam()->load(['projects'])->projects->where('uuid', request()->route('project_uuid'))->first();
|
|
|
|
if (!$project) {
|
2023-12-27 15:45:01 +00:00
|
|
|
return redirect()->route('dashboard');
|
2023-11-21 14:31:46 +00:00
|
|
|
}
|
|
|
|
$environment = $project->load(['environments'])->environments->where('name', request()->route('environment_name'))->first()->load(['applications']);
|
|
|
|
if (!$environment) {
|
2023-12-27 15:45:01 +00:00
|
|
|
return redirect()->route('dashboard');
|
2023-11-21 14:31:46 +00:00
|
|
|
}
|
|
|
|
$application = $environment->applications->where('uuid', request()->route('application_uuid'))->first();
|
|
|
|
if (!$application) {
|
2023-12-27 15:45:01 +00:00
|
|
|
return redirect()->route('dashboard');
|
2023-11-21 14:31:46 +00:00
|
|
|
}
|
|
|
|
$this->application = $application;
|
2023-12-04 19:47:32 +00:00
|
|
|
$mainServer = $this->application->destination->server;
|
2023-11-21 14:31:46 +00:00
|
|
|
$servers = Server::ownedByCurrentTeam()->get();
|
|
|
|
$this->servers = $servers->filter(function ($server) use ($mainServer) {
|
|
|
|
return $server->id != $mainServer->id;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.application.configuration');
|
|
|
|
}
|
|
|
|
}
|