From cb410f739da67c534624cfcf5f5ac1c04e2f1809 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 25 Mar 2022 12:46:49 +0100 Subject: [PATCH] Merge unset statements wherever possible --- application/models/Admins_model.php | 11 +++++++++-- application/models/Providers_model.php | 14 ++++++++++---- application/models/Secretaries_model.php | 17 +++++++++++------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/application/models/Admins_model.php b/application/models/Admins_model.php index bc041687..10baf1e5 100644 --- a/application/models/Admins_model.php +++ b/application/models/Admins_model.php @@ -194,7 +194,10 @@ class Admins_model extends EA_Model { $admin['id_roles'] = $this->get_admin_role_id(); $settings = $admin['settings']; - unset($admin['settings']); + + unset( + $admin['settings'] + ); $admin['create_datetime'] = date('Y-m-d H:i:s'); $admin['update_datetime'] = date('Y-m-d H:i:s'); @@ -225,8 +228,12 @@ class Admins_model extends EA_Model { protected function update(array $admin): int { $settings = $admin['settings']; + $settings['id_users'] = $admin['id']; - unset($admin['settings']); + + unset( + $admin['settings'] + ); if ( ! empty($settings['password'])) { diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 00977eb2..d754f0d4 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -211,10 +211,13 @@ class Providers_model extends EA_Model { $provider['id_roles'] = $this->get_provider_role_id(); $service_ids = $provider['services']; - unset($provider['services']); $settings = $provider['settings']; - unset($provider['settings']); + + unset( + $provider['services'], + $provider['settings'] + ); if ( ! $this->db->insert('users', $provider)) { @@ -245,10 +248,13 @@ class Providers_model extends EA_Model { $provider['update_datetime'] = date('Y-m-d H:i:s'); $service_ids = $provider['services']; - unset($provider['services']); $settings = $provider['settings']; - unset($provider['settings']); + + unset( + $provider['services'], + $provider['settings'] + ); if (isset($settings['password'])) { diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index 2eb9532d..fb54fcfb 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -209,12 +209,14 @@ class Secretaries_model extends EA_Model { $secretary['id_roles'] = $this->get_secretary_role_id(); - $providers = $secretary['providers'] ?? []; - unset($secretary['providers']); + $provider_ids = $secretary['providers'] ?? []; $settings = $secretary['settings']; - unset($secretary['settings']); + unset( + $secretary['providers'], + $secretary['settings'] + ); if ( ! $this->db->insert('users', $secretary)) { @@ -226,7 +228,7 @@ class Secretaries_model extends EA_Model { $settings['password'] = hash_password($settings['salt'], $settings['password']); $this->save_settings($secretary['id'], $settings); - $this->save_provider_ids($secretary['id'], $providers); + $this->save_provider_ids($secretary['id'], $provider_ids); return $secretary['id']; } @@ -245,10 +247,13 @@ class Secretaries_model extends EA_Model { $secretary['update_datetime'] = date('Y-m-d H:i:s'); $provider_ids = $secretary['providers'] ?? []; - unset($secretary['providers']); $settings = $secretary['settings']; - unset($secretary['settings']); + + unset( + $secretary['providers'], + $secretary['settings'] + ); if (isset($settings['password'])) {