From a48324be0828203cb01899a7f868004b9ca02cd7 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Mon, 16 Nov 2020 10:41:04 +0200 Subject: [PATCH] Minor changes to the model classes --- application/models/Admins_model.php | 2 +- application/models/Appointments_model.php | 3 ++- application/models/Customers_model.php | 2 +- application/models/Providers_model.php | 8 +++++--- application/models/Secretaries_model.php | 6 ++++-- application/models/Services_model.php | 21 +++++++++++++++------ 6 files changed, 28 insertions(+), 14 deletions(-) diff --git a/application/models/Admins_model.php b/application/models/Admins_model.php index 8d3e2739..033ed6cc 100644 --- a/application/models/Admins_model.php +++ b/application/models/Admins_model.php @@ -156,7 +156,7 @@ class Admins_model extends EA_Model { { $num_rows = $this->db->get_where('user_settings', ['username' => $username, 'id_users <> ' => $user_id])->num_rows(); - return ($num_rows > 0) ? FALSE : TRUE; + return $num_rows > 0 ? FALSE : TRUE; } /** diff --git a/application/models/Appointments_model.php b/application/models/Appointments_model.php index 7d6a2e13..d7fbcb88 100644 --- a/application/models/Appointments_model.php +++ b/application/models/Appointments_model.php @@ -232,7 +232,7 @@ class Appointments_model extends EA_Model { ]) ->num_rows(); - return ($num_rows > 0) ? TRUE : FALSE; + return $num_rows > 0; } /** @@ -381,6 +381,7 @@ class Appointments_model extends EA_Model { * @param bool $aggregates (OPTIONAL) Defines whether to add aggregations or not. * * @return array Returns the rows from the database. + * @throws Exception */ public function get_batch($where = NULL, $order_by = NULL, $limit = NULL, $offset = NULL, $aggregates = FALSE) { diff --git a/application/models/Customers_model.php b/application/models/Customers_model.php index 7a5a03bb..51a7bccf 100644 --- a/application/models/Customers_model.php +++ b/application/models/Customers_model.php @@ -158,7 +158,7 @@ class Customers_model extends EA_Model { ->where('roles.slug', DB_SLUG_CUSTOMER) ->get()->num_rows(); - return ($num_rows > 0) ? TRUE : FALSE; + return $num_rows > 0; } /** diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 6d703363..dfd4bb3f 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -187,7 +187,7 @@ class Providers_model extends EA_Model { { $num_rows = $this->db->get_where('user_settings', ['username' => $username, 'id_users <> ' => $user_id])->num_rows(); - return ($num_rows > 0) ? FALSE : TRUE; + return $num_rows > 0 ? FALSE : TRUE; } /** @@ -215,7 +215,7 @@ class Providers_model extends EA_Model { ->where('roles.slug', DB_SLUG_PROVIDER) ->get()->num_rows(); - return ($num_rows > 0) ? TRUE : FALSE; + return $num_rows > 0; } /** @@ -348,6 +348,8 @@ class Providers_model extends EA_Model { * @param string $setting_name The setting's name. * @param string $value The setting's value. * @param int $provider_id The selected provider id. + * + * @return bool */ public function set_setting($setting_name, $value, $provider_id) { @@ -429,7 +431,7 @@ class Providers_model extends EA_Model { /** * Delete an existing provider record from the database. * - * @param int $customer_id The record id to be deleted. + * @param $provider_id * * @return bool Returns the delete operation result. * diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index 6446b9ec..a7af7f46 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -165,7 +165,7 @@ class Secretaries_model extends EA_Model { { $num_rows = $this->db->get_where('user_settings', ['username' => $username, 'id_users <> ' => $user_id])->num_rows(); - return ($num_rows > 0) ? FALSE : TRUE; + return $num_rows > 0 ? FALSE : TRUE; } /** @@ -193,7 +193,7 @@ class Secretaries_model extends EA_Model { ->where('roles.slug', DB_SLUG_SECRETARY) ->get()->num_rows(); - return ($num_rows > 0) ? TRUE : FALSE; + return $num_rows > 0; } /** @@ -344,6 +344,8 @@ class Secretaries_model extends EA_Model { * @param string $setting_name The setting's name. * @param string $value The setting's value. * @param int $secretary_id The selected provider id. + * + * @return bool */ public function set_setting($setting_name, $value, $secretary_id) { diff --git a/application/models/Services_model.php b/application/models/Services_model.php index dcbb1c4a..e41a2e9f 100644 --- a/application/models/Services_model.php +++ b/application/models/Services_model.php @@ -186,17 +186,19 @@ class Services_model extends EA_Model { 'price' => $service['price'] ])->num_rows(); - return ($num_rows > 0) ? TRUE : FALSE; + return $num_rows > 0; } /** * Get the record id of an existing record. * - * NOTICE: The record must exist, otherwise an exception will be raised. + * Notice: The record must exist, otherwise an exception will be raised. * * @param array $service Contains the service record data. Name, duration and price values are mandatory for this * method to complete. * + * @return int + * * @throws Exception If required fields are missing. * @throws Exception If requested service was not found. */ @@ -312,12 +314,14 @@ class Services_model extends EA_Model { /** * Get all, or specific records from service's table. * - * @param string $whereClause (OPTIONAL) The WHERE clause of - * the query to be executed. DO NOT INCLUDE 'WHERE' KEYWORD. - * - * @return array Returns the rows from the database. * @example $this->Model->getBatch('id = ' . $recordId); * + * @param mixed $where + * @param mixed $order_by + * @param int|null $limit + * @param int|null $offset + * + * @return array Returns the rows from the database. */ public function get_batch($where = NULL, $order_by = NULL, $limit = NULL, $offset = NULL) { @@ -475,6 +479,11 @@ class Services_model extends EA_Model { /** * Get all service category records from database. * + * @param mixed $where + * @param mixed $order_by + * @param int|null $limit + * @param int|null $offset + * * @return array Returns an array that contains all the service category records. */ public function get_all_categories($where = NULL, $order_by = NULL, $limit = NULL, $offset = NULL)