coolify/app/Livewire/Project/Service/Index.php

64 lines
1.7 KiB
PHP
Raw Normal View History

2023-09-20 15:42:41 +02:00
<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire\Project\Service;
2023-09-20 15:42:41 +02:00
use App\Models\Service;
2024-01-07 16:23:41 +01:00
use App\Models\ServiceApplication;
use App\Models\ServiceDatabase;
use Illuminate\Support\Collection;
2023-09-20 15:42:41 +02:00
use Livewire\Component;
class Index extends Component
{
public ?Service $service = null;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public ?ServiceApplication $serviceApplication = null;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public ?ServiceDatabase $serviceDatabase = null;
2024-06-10 22:43:34 +02:00
2023-09-20 15:42:41 +02:00
public array $parameters;
2024-06-10 22:43:34 +02:00
2023-09-20 15:42:41 +02:00
public array $query;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public Collection $services;
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public $s3s;
protected $listeners = ['generateDockerCompose'];
public function mount()
{
2024-01-07 16:23:41 +01:00
try {
$this->services = collect([]);
$this->parameters = get_route_parameters();
$this->query = request()->query();
$this->service = Service::whereUuid($this->parameters['service_uuid'])->first();
2024-06-10 22:43:34 +02:00
if (! $this->service) {
return redirect()->route('dashboard');
}
$service = $this->service->applications()->whereUuid($this->parameters['stack_service_uuid'])->first();
2024-01-07 16:23:41 +01:00
if ($service) {
$this->serviceApplication = $service;
$this->serviceApplication->getFilesFromServer();
} else {
$this->serviceDatabase = $this->service->databases()->whereUuid($this->parameters['stack_service_uuid'])->first();
2024-01-07 16:23:41 +01:00
$this->serviceDatabase->getFilesFromServer();
}
$this->s3s = currentTeam()->s3s;
2024-06-10 22:43:34 +02:00
} catch (\Throwable $e) {
2024-01-07 16:23:41 +01:00
return handleError($e, $this);
}
}
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public function generateDockerCompose()
{
2024-01-07 16:23:41 +01:00
$this->service->parse();
2023-09-26 14:45:52 +02:00
}
2024-06-10 22:43:34 +02:00
2024-01-07 16:23:41 +01:00
public function render()
2023-09-26 14:45:52 +02:00
{
2024-01-07 16:23:41 +01:00
return view('livewire.project.service.index');
2023-09-26 14:45:52 +02:00
}
2023-09-20 15:42:41 +02:00
}