Update ModelHostingSubscriptionDeletingListener.php

This commit is contained in:
Bozhidar Slaveykov 2024-04-06 12:14:04 +03:00
parent ccbce0ba45
commit e6e764b98d

View file

@ -5,6 +5,7 @@ namespace App\Listeners;
use App\Actions\GetLinuxUser;
use App\Events\ModelHostingSubscriptionCreated;
use App\Events\ModelHostingSubscriptionDeleting;
use App\Models\Domain;
class ModelHostingSubscriptionDeletingListener
{
@ -29,6 +30,12 @@ class ModelHostingSubscriptionDeletingListener
shell_exec('userdel ' . $event->model->system_username);
shell_exec('rm -rf /home/' . $event->model->system_username);
}
$findRelatedDomains = Domain::where('hosting_subscription_id', $event->model->id)->get();
if ($findRelatedDomains->count() > 0) {
foreach ($findRelatedDomains as $domain) {
$domain->delete();
}
}
}