From 359b574ba8ab968134f6bee0a944bba5689ed313 Mon Sep 17 00:00:00 2001 From: rokumens <7381@asiapowergames.com> Date: Mon, 21 Dec 2020 08:38:01 +0700 Subject: [PATCH] use count to use check return by ->get() --- addons/vultr/helpers/ProductsHelper.php | 4 ++-- servers/vultr/controller/main.controller.php | 4 ++-- servers/vultr/controller/sshkeys.controller.php | 2 +- servers/vultr/helper/vultr.helper.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/addons/vultr/helpers/ProductsHelper.php b/addons/vultr/helpers/ProductsHelper.php index 08d579b..cd24f2c 100755 --- a/addons/vultr/helpers/ProductsHelper.php +++ b/addons/vultr/helpers/ProductsHelper.php @@ -25,7 +25,7 @@ private static function prepareConfigurableOptions($vultrAPI, $productID) { $checkIsset = DB::table('tblproductconfiglinks')->where('pid', $productID)->get(); - if ($checkIsset) + if (count($checkIsset) > 0) { return array('status' => false, 'message' => 'Product configurable options already exist!'); } @@ -116,7 +116,7 @@ public static function getProductConfigOptions($productID, $field = 'all', $defa public static function customFields($productID) { $result = DB::table('tblcustomfields')->where('fieldname', 'subid|Virtual machine ID')->where('type', 'product')->where('relid', $productID)->select('id')->get(); - if (!$result) + if (count($result) < 1) { DB::table('tblcustomfields')->insert(array('type' => 'product', 'relid' => $productID, 'fieldname' => 'subid|Virtual machine ID', 'fieldtype' => 'text', 'adminonly' => 'on')); return array('status' => true, 'reload' => true, 'message' => 'success'); diff --git a/servers/vultr/controller/main.controller.php b/servers/vultr/controller/main.controller.php index 90fe737..ad97a50 100755 --- a/servers/vultr/controller/main.controller.php +++ b/servers/vultr/controller/main.controller.php @@ -377,12 +377,12 @@ private function addVMCustomFields($SUBID) ->where('type', 'product') ->where('relid', $this->params['packageid']) ->where('fieldname', 'LIKE', 'subid|%')->get(); - if ($customField) + if (count($customField) > 0) { $customFieldValue = Capsule::table('tblcustomfieldsvalues') ->where('fieldid', $customField[0]->id) ->where('relid', $this->serviceID)->get(); - if ($customFieldValue) + if (count($customFieldValue) > 0) { $customFieldValue = Capsule::table('tblcustomfieldsvalues') ->where('fieldid', $customField[0]->id) diff --git a/servers/vultr/controller/sshkeys.controller.php b/servers/vultr/controller/sshkeys.controller.php index e11189f..32f0e13 100755 --- a/servers/vultr/controller/sshkeys.controller.php +++ b/servers/vultr/controller/sshkeys.controller.php @@ -15,7 +15,7 @@ public function indexAction() if ($this->getVultrAPI()) { $allowKeys = Capsule::table('vultr_sshkeys')->where('client_id', $this->clientID)->get(); - if (empty($allowKeys)) + if (count($allowKeys) < 1) { return array(); } diff --git a/servers/vultr/helper/vultr.helper.php b/servers/vultr/helper/vultr.helper.php index 240ae82..b6fa41f 100755 --- a/servers/vultr/helper/vultr.helper.php +++ b/servers/vultr/helper/vultr.helper.php @@ -490,7 +490,7 @@ public static function getAvailableIsos($isosList) public static function getUserScripts($clientID, $scripts) { $allowScripts = Capsule::table('vultr_scripts')->where('client_id', $clientID)->get(); - if (empty($allowScripts)) + if (count($allowScripts) < 1) { return array(); } @@ -521,7 +521,7 @@ public static function getUserScripts($clientID, $scripts) public static function getUserSSHKeys($clientID, $keys) { $allowKeys = Capsule::table('vultr_sshkeys')->where('client_id', $clientID)->get(); - if (empty($allowKeys)) + if (count($allowKeys) < 1) { return array(); }