From 469a6c8c4306991955d39894462be4634739cb5b Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Tue, 14 May 2024 13:27:07 +0300 Subject: [PATCH] Update Domain.php --- web/app/Models/Domain.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/web/app/Models/Domain.php b/web/app/Models/Domain.php index f6398b1..12eda92 100644 --- a/web/app/Models/Domain.php +++ b/web/app/Models/Domain.php @@ -83,14 +83,8 @@ class Domain extends Model }); - static::updating(function ($model) { - $model->configureVirtualHost(true); - }); - static::saved(function ($model) { - $model->configureVirtualHost(true); - $apacheBuild = new ApacheBuild(); $apacheBuild->build(); @@ -101,12 +95,14 @@ class Domain extends Model if (empty($model->domain_public)) { return; } - $findHostingSubscription = HostingSubscription::where('id', $model->hosting_subscription_id)->first(); - if (! $findHostingSubscription) { - return; - } - ShellApi::safeDelete($model->domain_root, ['/home/' . $findHostingSubscription->system_username]); + if ($model->is_main == 1) { + $findHostingSubscription = HostingSubscription::where('id', $model->hosting_subscription_id)->first(); + if (!$findHostingSubscription) { + return; + } + ShellApi::safeDelete($model->domain_root, ['/home/' . $findHostingSubscription->system_username]); + } });