Update PhyreServer.php

This commit is contained in:
Bozhidar Slaveykov 2024-04-07 15:20:17 +03:00
parent e26c1a0aad
commit 2d941960f4

View file

@ -93,28 +93,32 @@ class PhyreServer extends Model
$centralServerHostingSubscriptionsExternalIds[] = $customer->external_id;
}
}
// $getPhyreServerHostingSubscriptions = $phyreApiSDK->getHostingSubscriptions();
$getPhyreServerHostingSubscriptions = $phyreApiSDK->getHostingSubscriptions();
if (isset($getPhyreServerHostingSubscriptions['data']['HostingSubscriptions'])) {
foreach ($getPhyreServerHostingSubscriptions['data']['HostingSubscriptions'] as $phyreServerHostingSubscription) {
dd($centralServerHostingSubscriptionsExternalIds);
if (isset($getExternalHostingSubscriptions['data']['HostingSubscriptions'])) {
$externalHostingSubscriptionsIds = [];
foreach ($getExternalHostingSubscriptions['data']['HostingSubscriptions'] as $externalHostingSubscriptions) {
$externalHostingSubscriptionsIds[] = $externalHostingSubscriptions['id'];
$findHostingSubscription = HostingSubscription::where('external_id', $phyreServerHostingSubscription['id'])
->where('phyre_server_id', $this->id)
->first();
if (!$findHostingSubscription) {
$findHostingSubscription = new HostingSubscription();
$findHostingSubscription->phyre_server_id = $this->id;
$findHostingSubscription->external_id = $phyreServerHostingSubscription['id'];
}
// Delete hosting subscriptions to main server that are not in external server
foreach ($customerExternalIds as $customerExternalId) {
if (!in_array($customerExternalId, $externalCustomerIds)) {
$getCustomer = Customer::where('external_id', $customerExternalId)->first();
if ($getCustomer) {
$getCustomer->delete();
}
}
$findHostingSubscriptionCustomer = Customer::where('external_id', $phyreServerHostingSubscription['customer_id'])
->where('phyre_server_id', $this->id)
->first();
if ($findHostingSubscriptionCustomer) {
$findHostingSubscription->customer_id = $findHostingSubscriptionCustomer->id;
}
$findHostingSubscription->domain = $phyreServerHostingSubscription['domain'];
$findHostingSubscription->save();
}
}
dd($externalHostingSubscriptionsIds);
// // Sync Hosting Plans
@ -131,8 +135,8 @@ class PhyreServer extends Model
$ssh = new SSH2($this->ip);
if ($ssh->login($this->username, $this->password)) {
$output = $ssh->exec('cd /usr/local/phyre/web && /usr/local/phyre/php/bin/php artisan apache:ping-websites-with-curl');
dd($output);
// $output = $ssh->exec('cd /usr/local/phyre/web && /usr/local/phyre/php/bin/php artisan apache:ping-websites-with-curl');
// dd($output);
$output = '';
$output .= $ssh->exec('wget https://raw.githubusercontent.com/CloudVisionApps/PhyrePanel/main/update/update-web-panel.sh -O /usr/local/phyre/update/update-web-panel.sh');