diff --git a/app/Livewire/Concerns/SynchronizesModelData.php b/app/Livewire/Concerns/SynchronizesModelData.php new file mode 100644 index 000000000..f8218c715 --- /dev/null +++ b/app/Livewire/Concerns/SynchronizesModelData.php @@ -0,0 +1,35 @@ + Array mapping property names to model keys (e.g., ['content' => 'fileStorage.content']) + */ + abstract protected function getModelBindings(): array; + + /** + * Synchronize component properties TO the model. + * Copies values from component properties to the model. + */ + protected function syncToModel(): void + { + foreach ($this->getModelBindings() as $property => $modelKey) { + data_set($this, $modelKey, $this->{$property}); + } + } + + /** + * Synchronize component properties FROM the model. + * Copies values from the model to component properties. + */ + protected function syncFromModel(): void + { + foreach ($this->getModelBindings() as $property => $modelKey) { + $this->{$property} = data_get($this, $modelKey); + } + } +} diff --git a/app/Livewire/Project/Application/General.php b/app/Livewire/Project/Application/General.php index bca1f67bc..a733d8cb3 100644 --- a/app/Livewire/Project/Application/General.php +++ b/app/Livewire/Project/Application/General.php @@ -3,6 +3,7 @@ namespace App\Livewire\Project\Application; use App\Actions\Application\GenerateConfig; +use App\Livewire\Concerns\SynchronizesModelData; use App\Models\Application; use App\Support\ValidationPatterns; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; @@ -14,6 +15,7 @@ class General extends Component { use AuthorizesRequests; + use SynchronizesModelData; public string $applicationId; @@ -264,14 +266,14 @@ public function mount() if (is_null($this->parsedServices) || empty($this->parsedServices)) { $this->dispatch('error', 'Failed to parse your docker-compose file. Please check the syntax and try again.'); // Still sync data even if parse fails, so form fields are populated - $this->syncData(false); + $this->syncFromModel(); return; } } catch (\Throwable $e) { $this->dispatch('error', $e->getMessage()); // Still sync data even on error, so form fields are populated - $this->syncData(false); + $this->syncFromModel(); } if ($this->application->build_pack === 'dockercompose') { // Only update if user has permission @@ -323,102 +325,57 @@ public function mount() // Sync data from model to properties at the END, after all business logic // This ensures any modifications to $this->application during mount() are reflected in properties - $this->syncData(false); + $this->syncFromModel(); } - private function syncData(bool $toModel = false): void + protected function getModelBindings(): array { - if ($toModel) { - $this->application->name = $this->name; - $this->application->description = $this->description; - $this->application->fqdn = $this->fqdn; - $this->application->git_repository = $this->git_repository; - $this->application->git_branch = $this->git_branch; - $this->application->git_commit_sha = $this->git_commit_sha; - $this->application->install_command = $this->install_command; - $this->application->build_command = $this->build_command; - $this->application->start_command = $this->start_command; - $this->application->build_pack = $this->build_pack; - $this->application->static_image = $this->static_image; - $this->application->base_directory = $this->base_directory; - $this->application->publish_directory = $this->publish_directory; - $this->application->ports_exposes = $this->ports_exposes; - $this->application->ports_mappings = $this->ports_mappings; - $this->application->custom_network_aliases = $this->custom_network_aliases; - $this->application->dockerfile = $this->dockerfile; - $this->application->dockerfile_location = $this->dockerfile_location; - $this->application->dockerfile_target_build = $this->dockerfile_target_build; - $this->application->docker_registry_image_name = $this->docker_registry_image_name; - $this->application->docker_registry_image_tag = $this->docker_registry_image_tag; - $this->application->docker_compose_location = $this->docker_compose_location; - $this->application->docker_compose = $this->docker_compose; - $this->application->docker_compose_raw = $this->docker_compose_raw; - $this->application->docker_compose_custom_start_command = $this->docker_compose_custom_start_command; - $this->application->docker_compose_custom_build_command = $this->docker_compose_custom_build_command; - $this->application->custom_labels = $this->custom_labels; - $this->application->custom_docker_run_options = $this->custom_docker_run_options; - $this->application->pre_deployment_command = $this->pre_deployment_command; - $this->application->pre_deployment_command_container = $this->pre_deployment_command_container; - $this->application->post_deployment_command = $this->post_deployment_command; - $this->application->post_deployment_command_container = $this->post_deployment_command_container; - $this->application->custom_nginx_configuration = $this->custom_nginx_configuration; - $this->application->settings->is_static = $this->is_static; - $this->application->settings->is_spa = $this->is_spa; - $this->application->settings->is_build_server_enabled = $this->is_build_server_enabled; - $this->application->settings->is_preserve_repository_enabled = $this->is_preserve_repository_enabled; - $this->application->settings->is_container_label_escape_enabled = $this->is_container_label_escape_enabled; - $this->application->settings->is_container_label_readonly_enabled = $this->is_container_label_readonly_enabled; - $this->application->is_http_basic_auth_enabled = $this->is_http_basic_auth_enabled; - $this->application->http_basic_auth_username = $this->http_basic_auth_username; - $this->application->http_basic_auth_password = $this->http_basic_auth_password; - $this->application->watch_paths = $this->watch_paths; - $this->application->redirect = $this->redirect; - } else { - $this->name = $this->application->name; - $this->description = $this->application->description; - $this->fqdn = $this->application->fqdn; - $this->git_repository = $this->application->git_repository; - $this->git_branch = $this->application->git_branch; - $this->git_commit_sha = $this->application->git_commit_sha; - $this->install_command = $this->application->install_command; - $this->build_command = $this->application->build_command; - $this->start_command = $this->application->start_command; - $this->build_pack = $this->application->build_pack; - $this->static_image = $this->application->static_image; - $this->base_directory = $this->application->base_directory; - $this->publish_directory = $this->application->publish_directory; - $this->ports_exposes = $this->application->ports_exposes; - $this->ports_mappings = $this->application->ports_mappings; - $this->custom_network_aliases = $this->application->custom_network_aliases; - $this->dockerfile = $this->application->dockerfile; - $this->dockerfile_location = $this->application->dockerfile_location; - $this->dockerfile_target_build = $this->application->dockerfile_target_build; - $this->docker_registry_image_name = $this->application->docker_registry_image_name; - $this->docker_registry_image_tag = $this->application->docker_registry_image_tag; - $this->docker_compose_location = $this->application->docker_compose_location; - $this->docker_compose = $this->application->docker_compose; - $this->docker_compose_raw = $this->application->docker_compose_raw; - $this->docker_compose_custom_start_command = $this->application->docker_compose_custom_start_command; - $this->docker_compose_custom_build_command = $this->application->docker_compose_custom_build_command; - $this->custom_labels = $this->application->custom_labels; - $this->custom_docker_run_options = $this->application->custom_docker_run_options; - $this->pre_deployment_command = $this->application->pre_deployment_command; - $this->pre_deployment_command_container = $this->application->pre_deployment_command_container; - $this->post_deployment_command = $this->application->post_deployment_command; - $this->post_deployment_command_container = $this->application->post_deployment_command_container; - $this->custom_nginx_configuration = $this->application->custom_nginx_configuration; - $this->is_static = $this->application->settings->is_static ?? false; - $this->is_spa = $this->application->settings->is_spa ?? false; - $this->is_build_server_enabled = $this->application->settings->is_build_server_enabled ?? false; - $this->is_preserve_repository_enabled = $this->application->settings->is_preserve_repository_enabled ?? false; - $this->is_container_label_escape_enabled = $this->application->settings->is_container_label_escape_enabled ?? true; - $this->is_container_label_readonly_enabled = $this->application->settings->is_container_label_readonly_enabled ?? false; - $this->is_http_basic_auth_enabled = $this->application->is_http_basic_auth_enabled ?? false; - $this->http_basic_auth_username = $this->application->http_basic_auth_username; - $this->http_basic_auth_password = $this->application->http_basic_auth_password; - $this->watch_paths = $this->application->watch_paths; - $this->redirect = $this->application->redirect; - } + return [ + 'name' => 'application.name', + 'description' => 'application.description', + 'fqdn' => 'application.fqdn', + 'git_repository' => 'application.git_repository', + 'git_branch' => 'application.git_branch', + 'git_commit_sha' => 'application.git_commit_sha', + 'install_command' => 'application.install_command', + 'build_command' => 'application.build_command', + 'start_command' => 'application.start_command', + 'build_pack' => 'application.build_pack', + 'static_image' => 'application.static_image', + 'base_directory' => 'application.base_directory', + 'publish_directory' => 'application.publish_directory', + 'ports_exposes' => 'application.ports_exposes', + 'ports_mappings' => 'application.ports_mappings', + 'custom_network_aliases' => 'application.custom_network_aliases', + 'dockerfile' => 'application.dockerfile', + 'dockerfile_location' => 'application.dockerfile_location', + 'dockerfile_target_build' => 'application.dockerfile_target_build', + 'docker_registry_image_name' => 'application.docker_registry_image_name', + 'docker_registry_image_tag' => 'application.docker_registry_image_tag', + 'docker_compose_location' => 'application.docker_compose_location', + 'docker_compose' => 'application.docker_compose', + 'docker_compose_raw' => 'application.docker_compose_raw', + 'docker_compose_custom_start_command' => 'application.docker_compose_custom_start_command', + 'docker_compose_custom_build_command' => 'application.docker_compose_custom_build_command', + 'custom_labels' => 'application.custom_labels', + 'custom_docker_run_options' => 'application.custom_docker_run_options', + 'pre_deployment_command' => 'application.pre_deployment_command', + 'pre_deployment_command_container' => 'application.pre_deployment_command_container', + 'post_deployment_command' => 'application.post_deployment_command', + 'post_deployment_command_container' => 'application.post_deployment_command_container', + 'custom_nginx_configuration' => 'application.custom_nginx_configuration', + 'is_static' => 'application.settings.is_static', + 'is_spa' => 'application.settings.is_spa', + 'is_build_server_enabled' => 'application.settings.is_build_server_enabled', + 'is_preserve_repository_enabled' => 'application.settings.is_preserve_repository_enabled', + 'is_container_label_escape_enabled' => 'application.settings.is_container_label_escape_enabled', + 'is_container_label_readonly_enabled' => 'application.settings.is_container_label_readonly_enabled', + 'is_http_basic_auth_enabled' => 'application.is_http_basic_auth_enabled', + 'http_basic_auth_username' => 'application.http_basic_auth_username', + 'http_basic_auth_password' => 'application.http_basic_auth_password', + 'watch_paths' => 'application.watch_paths', + 'redirect' => 'application.redirect', + ]; } public function instantSave() @@ -430,7 +387,7 @@ public function instantSave() $oldIsContainerLabelEscapeEnabled = $this->application->settings->is_container_label_escape_enabled; $oldIsPreserveRepositoryEnabled = $this->application->settings->is_preserve_repository_enabled; - $this->syncData(true); + $this->syncToModel(); if ($this->application->settings->isDirty('is_spa')) { $this->generateNginxConfiguration($this->application->settings->is_spa ? 'spa' : 'static'); @@ -441,7 +398,7 @@ public function instantSave() $this->application->settings->save(); $this->dispatch('success', 'Settings saved.'); $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); // If port_exposes changed, reset default labels if ($oldPortsExposes !== $this->ports_exposes || $oldIsContainerLabelEscapeEnabled !== $this->is_container_label_escape_enabled) { @@ -565,13 +522,13 @@ public function updatedBuildPack() } catch (\Illuminate\Auth\Access\AuthorizationException $e) { // User doesn't have permission, revert the change and return $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); return; } // Sync property to model before checking/modifying - $this->syncData(true); + $this->syncToModel(); if ($this->build_pack !== 'nixpacks') { $this->is_static = false; @@ -624,10 +581,10 @@ public function getWildcardDomain() if ($server) { $fqdn = generateUrl(server: $server, random: $this->application->uuid); $this->fqdn = $fqdn; - $this->syncData(true); + $this->syncToModel(); $this->application->save(); $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); $this->resetDefaultLabels(); $this->dispatch('success', 'Wildcard domain generated.'); } @@ -642,10 +599,10 @@ public function generateNginxConfiguration($type = 'static') $this->authorize('update', $this->application); $this->custom_nginx_configuration = defaultNginxConfiguration($type); - $this->syncData(true); + $this->syncToModel(); $this->application->save(); $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); $this->dispatch('success', 'Nginx configuration generated.'); } catch (\Throwable $e) { return handleError($e, $this); @@ -660,10 +617,10 @@ public function resetDefaultLabels($manualReset = false) } $this->customLabels = str(implode('|coolify|', generateLabelsApplication($this->application)))->replace('|coolify|', "\n"); $this->custom_labels = base64_encode($this->customLabels); - $this->syncData(true); + $this->syncToModel(); $this->application->save(); $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); if ($this->build_pack === 'dockercompose') { $this->loadComposeFile(showToast: false); } @@ -760,7 +717,7 @@ public function submit($showToaster = true) $this->dispatch('warning', __('warning.sslipdomain')); } - $this->syncData(true); + $this->syncToModel(); if ($this->application->isDirty('redirect')) { $this->setRedirect(); @@ -847,11 +804,11 @@ public function submit($showToaster = true) $this->application->custom_labels = base64_encode($this->customLabels); $this->application->save(); $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); $showToaster && ! $warning && $this->dispatch('success', 'Application settings updated!'); } catch (\Throwable $e) { $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); return handleError($e, $this); } finally { diff --git a/app/Livewire/Project/Service/EditDomain.php b/app/Livewire/Project/Service/EditDomain.php index c45386d2e..43d885238 100644 --- a/app/Livewire/Project/Service/EditDomain.php +++ b/app/Livewire/Project/Service/EditDomain.php @@ -2,12 +2,14 @@ namespace App\Livewire\Project\Service; +use App\Livewire\Concerns\SynchronizesModelData; use App\Models\ServiceApplication; use Livewire\Component; use Spatie\Url\Url; class EditDomain extends Component { + use SynchronizesModelData; public $applicationId; public ServiceApplication $application; @@ -28,16 +30,14 @@ public function mount() { $this->application = ServiceApplication::query()->findOrFail($this->applicationId); $this->authorize('view', $this->application); - $this->syncData(false); + $this->syncFromModel(); } - private function syncData(bool $toModel = false): void + protected function getModelBindings(): array { - if ($toModel) { - $this->application->fqdn = $this->fqdn; - } else { - $this->fqdn = $this->application->fqdn; - } + return [ + 'fqdn' => 'application.fqdn', + ]; } public function confirmDomainUsage() @@ -65,7 +65,7 @@ public function submit() $this->dispatch('warning', __('warning.sslipdomain')); } // Sync to model for domain conflict check - $this->syncData(true); + $this->syncToModel(); // Check for domain conflicts if not forcing save if (! $this->forceSaveDomains) { $result = checkDomainUsage(resource: $this->application); diff --git a/app/Livewire/Project/Service/FileStorage.php b/app/Livewire/Project/Service/FileStorage.php index 390836243..40539b13e 100644 --- a/app/Livewire/Project/Service/FileStorage.php +++ b/app/Livewire/Project/Service/FileStorage.php @@ -2,6 +2,7 @@ namespace App\Livewire\Project\Service; +use App\Livewire\Concerns\SynchronizesModelData; use App\Models\Application; use App\Models\InstanceSettings; use App\Models\LocalFileVolume; @@ -22,7 +23,7 @@ class FileStorage extends Component { - use AuthorizesRequests; + use AuthorizesRequests, SynchronizesModelData; public LocalFileVolume $fileStorage; @@ -60,18 +61,15 @@ public function mount() } $this->isReadOnly = $this->fileStorage->isReadOnlyVolume(); - $this->syncData(false); + $this->syncFromModel(); } - private function syncData(bool $toModel = false): void + protected function getModelBindings(): array { - if ($toModel) { - $this->fileStorage->content = $this->content; - $this->fileStorage->is_based_on_git = $this->isBasedOnGit; - } else { - $this->content = $this->fileStorage->content; - $this->isBasedOnGit = $this->fileStorage->is_based_on_git ?? false; - } + return [ + 'content' => 'fileStorage.content', + 'isBasedOnGit' => 'fileStorage.is_based_on_git', + ]; } public function convertToDirectory() @@ -98,7 +96,7 @@ public function loadStorageOnServer() $this->authorize('update', $this->resource); $this->fileStorage->loadStorageOnServer(); - $this->syncData(false); + $this->syncFromModel(); $this->dispatch('success', 'File storage loaded from server.'); } catch (\Throwable $e) { return handleError($e, $this); @@ -167,14 +165,14 @@ public function submit() if ($this->fileStorage->is_directory) { $this->content = null; } - $this->syncData(true); + $this->syncToModel(); $this->fileStorage->save(); $this->fileStorage->saveStorageOnServer(); $this->dispatch('success', 'File updated.'); } catch (\Throwable $e) { $this->fileStorage->setRawAttributes($original); $this->fileStorage->save(); - $this->syncData(false); + $this->syncFromModel(); return handleError($e, $this); } diff --git a/app/Livewire/Project/Service/ServiceApplicationView.php b/app/Livewire/Project/Service/ServiceApplicationView.php index 7e1f737db..20358218f 100644 --- a/app/Livewire/Project/Service/ServiceApplicationView.php +++ b/app/Livewire/Project/Service/ServiceApplicationView.php @@ -2,6 +2,7 @@ namespace App\Livewire\Project\Service; +use App\Livewire\Concerns\SynchronizesModelData; use App\Models\InstanceSettings; use App\Models\ServiceApplication; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; @@ -14,6 +15,7 @@ class ServiceApplicationView extends Component { use AuthorizesRequests; + use SynchronizesModelData; public ServiceApplication $application; @@ -77,7 +79,7 @@ public function instantSaveAdvanced() return; } - $this->syncData(true); + $this->syncToModel(); $this->application->save(); $this->dispatch('success', 'You need to restart the service for the changes to take effect.'); } catch (\Throwable $e) { @@ -112,33 +114,24 @@ public function mount() try { $this->parameters = get_route_parameters(); $this->authorize('view', $this->application); - $this->syncData(false); + $this->syncFromModel(); } catch (\Throwable $e) { return handleError($e, $this); } } - private function syncData(bool $toModel = false): void + protected function getModelBindings(): array { - if ($toModel) { - $this->application->human_name = $this->humanName; - $this->application->description = $this->description; - $this->application->fqdn = $this->fqdn; - $this->application->image = $this->image; - $this->application->exclude_from_status = $this->excludeFromStatus; - $this->application->is_log_drain_enabled = $this->isLogDrainEnabled; - $this->application->is_gzip_enabled = $this->isGzipEnabled; - $this->application->is_stripprefix_enabled = $this->isStripprefixEnabled; - } else { - $this->humanName = $this->application->human_name; - $this->description = $this->application->description; - $this->fqdn = $this->application->fqdn; - $this->image = $this->application->image; - $this->excludeFromStatus = $this->application->exclude_from_status ?? false; - $this->isLogDrainEnabled = $this->application->is_log_drain_enabled ?? false; - $this->isGzipEnabled = $this->application->is_gzip_enabled ?? false; - $this->isStripprefixEnabled = $this->application->is_stripprefix_enabled ?? false; - } + return [ + 'humanName' => 'application.human_name', + 'description' => 'application.description', + 'fqdn' => 'application.fqdn', + 'image' => 'application.image', + 'excludeFromStatus' => 'application.exclude_from_status', + 'isLogDrainEnabled' => 'application.is_log_drain_enabled', + 'isGzipEnabled' => 'application.is_gzip_enabled', + 'isStripprefixEnabled' => 'application.is_stripprefix_enabled', + ]; } public function convertToDatabase() @@ -201,7 +194,7 @@ public function submit() $this->dispatch('warning', __('warning.sslipdomain')); } // Sync to model for domain conflict check - $this->syncData(true); + $this->syncToModel(); // Check for domain conflicts if not forcing save if (! $this->forceSaveDomains) { $result = checkDomainUsage(resource: $this->application); @@ -219,7 +212,7 @@ public function submit() $this->validate(); $this->application->save(); $this->application->refresh(); - $this->syncData(false); + $this->syncFromModel(); updateCompose($this->application); if (str($this->application->fqdn)->contains(',')) { $this->dispatch('warning', 'Some services do not support multiple domains, which can lead to problems and is NOT RECOMMENDED.

Only use multiple domains if you know what you are doing.'); @@ -231,7 +224,7 @@ public function submit() $originalFqdn = $this->application->getOriginal('fqdn'); if ($originalFqdn !== $this->application->fqdn) { $this->application->fqdn = $originalFqdn; - $this->syncData(false); + $this->syncFromModel(); } return handleError($e, $this); diff --git a/app/Livewire/Project/Shared/HealthChecks.php b/app/Livewire/Project/Shared/HealthChecks.php index a9ac35e70..c8029761d 100644 --- a/app/Livewire/Project/Shared/HealthChecks.php +++ b/app/Livewire/Project/Shared/HealthChecks.php @@ -2,12 +2,14 @@ namespace App\Livewire\Project\Shared; +use App\Livewire\Concerns\SynchronizesModelData; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Livewire\Component; class HealthChecks extends Component { use AuthorizesRequests; + use SynchronizesModelData; public $resource; @@ -54,57 +56,36 @@ class HealthChecks extends Component 'customHealthcheckFound' => 'boolean', ]; - /** - * Sync data between component properties and model - * - * @param bool $toModel If true, sync FROM properties TO model. If false, sync FROM model TO properties. - */ - private function syncData(bool $toModel = false): void + protected function getModelBindings(): array { - if ($toModel) { - // Sync TO model (before save) - $this->resource->health_check_enabled = $this->healthCheckEnabled; - $this->resource->health_check_method = $this->healthCheckMethod; - $this->resource->health_check_scheme = $this->healthCheckScheme; - $this->resource->health_check_host = $this->healthCheckHost; - $this->resource->health_check_port = $this->healthCheckPort; - $this->resource->health_check_path = $this->healthCheckPath; - $this->resource->health_check_return_code = $this->healthCheckReturnCode; - $this->resource->health_check_response_text = $this->healthCheckResponseText; - $this->resource->health_check_interval = $this->healthCheckInterval; - $this->resource->health_check_timeout = $this->healthCheckTimeout; - $this->resource->health_check_retries = $this->healthCheckRetries; - $this->resource->health_check_start_period = $this->healthCheckStartPeriod; - $this->resource->custom_healthcheck_found = $this->customHealthcheckFound; - } else { - // Sync FROM model (on load/refresh) - $this->healthCheckEnabled = $this->resource->health_check_enabled; - $this->healthCheckMethod = $this->resource->health_check_method; - $this->healthCheckScheme = $this->resource->health_check_scheme; - $this->healthCheckHost = $this->resource->health_check_host; - $this->healthCheckPort = $this->resource->health_check_port; - $this->healthCheckPath = $this->resource->health_check_path; - $this->healthCheckReturnCode = $this->resource->health_check_return_code; - $this->healthCheckResponseText = $this->resource->health_check_response_text; - $this->healthCheckInterval = $this->resource->health_check_interval; - $this->healthCheckTimeout = $this->resource->health_check_timeout; - $this->healthCheckRetries = $this->resource->health_check_retries; - $this->healthCheckStartPeriod = $this->resource->health_check_start_period; - $this->customHealthcheckFound = $this->resource->custom_healthcheck_found; - } + return [ + 'healthCheckEnabled' => 'resource.health_check_enabled', + 'healthCheckMethod' => 'resource.health_check_method', + 'healthCheckScheme' => 'resource.health_check_scheme', + 'healthCheckHost' => 'resource.health_check_host', + 'healthCheckPort' => 'resource.health_check_port', + 'healthCheckPath' => 'resource.health_check_path', + 'healthCheckReturnCode' => 'resource.health_check_return_code', + 'healthCheckResponseText' => 'resource.health_check_response_text', + 'healthCheckInterval' => 'resource.health_check_interval', + 'healthCheckTimeout' => 'resource.health_check_timeout', + 'healthCheckRetries' => 'resource.health_check_retries', + 'healthCheckStartPeriod' => 'resource.health_check_start_period', + 'customHealthcheckFound' => 'resource.custom_healthcheck_found', + ]; } public function mount() { $this->authorize('view', $this->resource); - $this->syncData(false); + $this->syncFromModel(); } public function instantSave() { $this->authorize('update', $this->resource); - $this->syncData(true); + $this->syncToModel(); $this->resource->save(); $this->dispatch('success', 'Health check updated.'); } @@ -115,7 +96,7 @@ public function submit() $this->authorize('update', $this->resource); $this->validate(); - $this->syncData(true); + $this->syncToModel(); $this->resource->save(); $this->dispatch('success', 'Health check updated.'); } catch (\Throwable $e) { @@ -130,7 +111,7 @@ public function toggleHealthcheck() $wasEnabled = $this->healthCheckEnabled; $this->healthCheckEnabled = ! $this->healthCheckEnabled; - $this->syncData(true); + $this->syncToModel(); $this->resource->save(); if ($this->healthCheckEnabled && ! $wasEnabled && $this->resource->isRunning()) {