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

53 lines
1.6 KiB
PHP
Raw Normal View History

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