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]); + } });