coolify/app/Livewire/Project/Shared/UploadConfig.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2024-10-08 13:11:19 +00:00
<?php
namespace App\Livewire\Project\Shared;
use App\Models\Application;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
2024-10-08 13:11:19 +00:00
use Livewire\Component;
class UploadConfig extends Component
{
use AuthorizesRequests;
2024-10-08 13:11:19 +00:00
public $config;
2024-10-17 20:08:23 +00:00
2024-10-08 13:11:19 +00:00
public $applicationId;
2024-10-17 20:08:23 +00:00
public function mount()
{
2024-10-08 13:11:19 +00:00
if (isDev()) {
$this->config = '{
"build_pack": "nixpacks",
"base_directory": "/nodejs",
"publish_directory": "/",
"ports_exposes": "3000",
"settings": {
"is_static": false
}
}';
}
}
2024-10-17 20:08:23 +00:00
2024-10-08 13:11:19 +00:00
public function uploadConfig()
{
try {
$application = Application::ownedByCurrentTeam()->findOrFail($this->applicationId);
$this->authorize('update', $application);
2024-10-08 13:11:19 +00:00
$application->setConfig($this->config);
$this->dispatch('success', 'Application settings updated');
} catch (\Throwable $e) {
return handleError($e, $this);
2024-10-08 13:11:19 +00:00
}
}
2024-10-17 20:08:23 +00:00
2024-10-08 13:11:19 +00:00
public function render()
{
return view('livewire.project.shared.upload-config');
}
}