Minor changes to the model classes

This commit is contained in:
Alex Tselegidis 2020-11-16 10:41:04 +02:00
parent 75a5addbc2
commit a48324be08
6 changed files with 28 additions and 14 deletions

View file

@ -156,7 +156,7 @@ class Admins_model extends EA_Model {
{ {
$num_rows = $this->db->get_where('user_settings', $num_rows = $this->db->get_where('user_settings',
['username' => $username, 'id_users <> ' => $user_id])->num_rows(); ['username' => $username, 'id_users <> ' => $user_id])->num_rows();
return ($num_rows > 0) ? FALSE : TRUE; return $num_rows > 0 ? FALSE : TRUE;
} }
/** /**

View file

@ -232,7 +232,7 @@ class Appointments_model extends EA_Model {
]) ])
->num_rows(); ->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. * @param bool $aggregates (OPTIONAL) Defines whether to add aggregations or not.
* *
* @return array Returns the rows from the database. * @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) public function get_batch($where = NULL, $order_by = NULL, $limit = NULL, $offset = NULL, $aggregates = FALSE)
{ {

View file

@ -158,7 +158,7 @@ class Customers_model extends EA_Model {
->where('roles.slug', DB_SLUG_CUSTOMER) ->where('roles.slug', DB_SLUG_CUSTOMER)
->get()->num_rows(); ->get()->num_rows();
return ($num_rows > 0) ? TRUE : FALSE; return $num_rows > 0;
} }
/** /**

View file

@ -187,7 +187,7 @@ class Providers_model extends EA_Model {
{ {
$num_rows = $this->db->get_where('user_settings', $num_rows = $this->db->get_where('user_settings',
['username' => $username, 'id_users <> ' => $user_id])->num_rows(); ['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) ->where('roles.slug', DB_SLUG_PROVIDER)
->get()->num_rows(); ->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 $setting_name The setting's name.
* @param string $value The setting's value. * @param string $value The setting's value.
* @param int $provider_id The selected provider id. * @param int $provider_id The selected provider id.
*
* @return bool
*/ */
public function set_setting($setting_name, $value, $provider_id) 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. * 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. * @return bool Returns the delete operation result.
* *

View file

@ -165,7 +165,7 @@ class Secretaries_model extends EA_Model {
{ {
$num_rows = $this->db->get_where('user_settings', $num_rows = $this->db->get_where('user_settings',
['username' => $username, 'id_users <> ' => $user_id])->num_rows(); ['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) ->where('roles.slug', DB_SLUG_SECRETARY)
->get()->num_rows(); ->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 $setting_name The setting's name.
* @param string $value The setting's value. * @param string $value The setting's value.
* @param int $secretary_id The selected provider id. * @param int $secretary_id The selected provider id.
*
* @return bool
*/ */
public function set_setting($setting_name, $value, $secretary_id) public function set_setting($setting_name, $value, $secretary_id)
{ {

View file

@ -186,17 +186,19 @@ class Services_model extends EA_Model {
'price' => $service['price'] 'price' => $service['price']
])->num_rows(); ])->num_rows();
return ($num_rows > 0) ? TRUE : FALSE; return $num_rows > 0;
} }
/** /**
* Get the record id of an existing record. * 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 * @param array $service Contains the service record data. Name, duration and price values are mandatory for this
* method to complete. * method to complete.
* *
* @return int
*
* @throws Exception If required fields are missing. * @throws Exception If required fields are missing.
* @throws Exception If requested service was not found. * @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. * 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); * @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) 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. * 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. * @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) public function get_all_categories($where = NULL, $order_by = NULL, $limit = NULL, $offset = NULL)