mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-22 22:52:35 +03:00
Removed unnecessary constructor methods from model classes.
This commit is contained in:
parent
6cda484e1d
commit
0caff545a9
9 changed files with 31 additions and 90 deletions
|
@ -33,13 +33,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Admins_Model extends CI_Model {
|
class Admins_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add (insert or update) an admin user record into database.
|
* Add (insert or update) an admin user record into database.
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,13 +17,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Appointments_Model extends CI_Model {
|
class Appointments_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an appointment record to the database.
|
* Add an appointment record to the database.
|
||||||
*
|
*
|
||||||
|
@ -68,7 +61,7 @@ class Appointments_Model extends CI_Model {
|
||||||
|| !isset($appointment['id_users_customer'])
|
|| !isset($appointment['id_users_customer'])
|
||||||
|| !isset($appointment['id_services'])) {
|
|| !isset($appointment['id_services'])) {
|
||||||
throw new Exception('Not all appointment field values '
|
throw new Exception('Not all appointment field values '
|
||||||
. 'are provided : ' . print_r($appointment, TRUE));
|
. 'are provided: ' . print_r($appointment, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_appointments', array(
|
$num_rows = $this->db->get_where('ea_appointments', array(
|
||||||
|
@ -253,7 +246,7 @@ class Appointments_Model extends CI_Model {
|
||||||
public function get_row($appointment_id) {
|
public function get_row($appointment_id) {
|
||||||
if (!is_numeric($appointment_id)) {
|
if (!is_numeric($appointment_id)) {
|
||||||
throw new Exception('Invalid argument given. Expected '
|
throw new Exception('Invalid argument given. Expected '
|
||||||
. 'integer for the $appointment_id : ' . $appointment_id);
|
. 'integer for the $appointment_id: ' . $appointment_id);
|
||||||
}
|
}
|
||||||
return $this->db->get_where('ea_appointments',
|
return $this->db->get_where('ea_appointments',
|
||||||
array('id' => $appointment_id))->row_array();
|
array('id' => $appointment_id))->row_array();
|
||||||
|
@ -269,18 +262,18 @@ class Appointments_Model extends CI_Model {
|
||||||
public function get_value($field_name, $appointment_id) {
|
public function get_value($field_name, $appointment_id) {
|
||||||
if (!is_numeric($appointment_id)) {
|
if (!is_numeric($appointment_id)) {
|
||||||
throw new Exception('Invalid argument given, expected '
|
throw new Exception('Invalid argument given, expected '
|
||||||
. 'integer for the $appointment_id : ' . $appointment_id);
|
. 'integer for the $appointment_id: ' . $appointment_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($field_name)) {
|
if (!is_string($field_name)) {
|
||||||
throw new Exception('Invalid argument given, expected '
|
throw new Exception('Invalid argument given, expected '
|
||||||
. 'string for the $field_name : ' . $field_name);
|
. 'string for the $field_name: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_appointments',
|
if ($this->db->get_where('ea_appointments',
|
||||||
array('id' => $appointment_id))->num_rows() == 0) {
|
array('id' => $appointment_id))->num_rows() == 0) {
|
||||||
throw new Exception('The record with the provided id '
|
throw new Exception('The record with the provided id '
|
||||||
. 'does not exist in the database : ' . $appointment_id);
|
. 'does not exist in the database: ' . $appointment_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('ea_appointments',
|
$row_data = $this->db->get_where('ea_appointments',
|
||||||
|
@ -288,7 +281,7 @@ class Appointments_Model extends CI_Model {
|
||||||
|
|
||||||
if (!isset($row_data[$field_name])) {
|
if (!isset($row_data[$field_name])) {
|
||||||
throw new Exception('The given field name does not '
|
throw new Exception('The given field name does not '
|
||||||
. 'exist in the database : ' . $field_name);
|
. 'exist in the database: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $row_data[$field_name];
|
return $row_data[$field_name];
|
||||||
|
|
|
@ -17,13 +17,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Customers_Model extends CI_Model {
|
class Customers_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a customer record to the database.
|
* Add a customer record to the database.
|
||||||
*
|
*
|
||||||
|
@ -148,7 +141,7 @@ class Customers_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function find_record_id($customer) {
|
public function find_record_id($customer) {
|
||||||
if (!isset($customer['email'])) {
|
if (!isset($customer['email'])) {
|
||||||
throw new Exception('Customer\'s email was not provided : '
|
throw new Exception('Customer\'s email was not provided: '
|
||||||
. print_r($customer, TRUE));
|
. print_r($customer, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,13 +184,13 @@ class Customers_Model extends CI_Model {
|
||||||
if (!isset($customer['last_name'])
|
if (!isset($customer['last_name'])
|
||||||
|| !isset($customer['email'])
|
|| !isset($customer['email'])
|
||||||
|| !isset($customer['phone_number'])) {
|
|| !isset($customer['phone_number'])) {
|
||||||
throw new Exception('Not all required fields are provided : '
|
throw new Exception('Not all required fields are provided: '
|
||||||
. print_r($customer, TRUE));
|
. print_r($customer, TRUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate email address
|
// Validate email address
|
||||||
if (!filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) {
|
if (!filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) {
|
||||||
throw new Exception('Invalid email address provided : '
|
throw new Exception('Invalid email address provided: '
|
||||||
. $customer['email']);
|
. $customer['email']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,7 +223,7 @@ class Customers_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function delete($customer_id) {
|
public function delete($customer_id) {
|
||||||
if (!is_numeric($customer_id)) {
|
if (!is_numeric($customer_id)) {
|
||||||
throw new Exception('Invalid argument type $customer_id : ' . $customer_id);
|
throw new Exception('Invalid argument type $customer_id: ' . $customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$num_rows = $this->db->get_where('ea_users', array('id' => $customer_id))->num_rows();
|
$num_rows = $this->db->get_where('ea_users', array('id' => $customer_id))->num_rows();
|
||||||
|
@ -266,25 +259,25 @@ class Customers_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function get_value($field_name, $customer_id) {
|
public function get_value($field_name, $customer_id) {
|
||||||
if (!is_numeric($customer_id)) {
|
if (!is_numeric($customer_id)) {
|
||||||
throw new Exception('Invalid argument provided as $customer_id : '
|
throw new Exception('Invalid argument provided as $customer_id: '
|
||||||
. $customer_id);
|
. $customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($field_name)) {
|
if (!is_string($field_name)) {
|
||||||
throw new Exception('$field_name argument is not a string : '
|
throw new Exception('$field_name argument is not a string: '
|
||||||
. $field_name);
|
. $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_users', array('id' => $customer_id))->num_rows() == 0) {
|
if ($this->db->get_where('ea_users', array('id' => $customer_id))->num_rows() == 0) {
|
||||||
throw new Exception('The record with the $customer_id argument '
|
throw new Exception('The record with the $customer_id argument '
|
||||||
. 'does not exist in the database : ' . $customer_id);
|
. 'does not exist in the database: ' . $customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('ea_users', array('id' => $customer_id)
|
$row_data = $this->db->get_where('ea_users', array('id' => $customer_id)
|
||||||
)->row_array();
|
)->row_array();
|
||||||
if (!isset($row_data[$field_name])) {
|
if (!isset($row_data[$field_name])) {
|
||||||
throw new Exception('The given $field_name argument does not'
|
throw new Exception('The given $field_name argument does not'
|
||||||
. 'exist in the database : ' . $field_name);
|
. 'exist in the database: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer = $this->db->get_where('ea_users', array('id' => $customer_id))->row_array();
|
$customer = $this->db->get_where('ea_users', array('id' => $customer_id))->row_array();
|
||||||
|
|
|
@ -45,13 +45,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Providers_Model extends CI_Model {
|
class Providers_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add (insert - update) a service provider record.
|
* Add (insert - update) a service provider record.
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,13 +17,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Roles_Model extends CI_Model {
|
class Roles_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the record id of a particular role.
|
* Get the record id of a particular role.
|
||||||
*
|
*
|
||||||
|
|
|
@ -34,13 +34,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Secretaries_Model extends CI_Model {
|
class Secretaries_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add (insert or update) a secretary user record into database.
|
* Add (insert or update) a secretary user record into database.
|
||||||
*
|
*
|
||||||
|
|
|
@ -17,13 +17,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Services_Model extends CI_Model {
|
class Services_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add (insert or update) a service record on the database
|
* Add (insert or update) a service record on the database
|
||||||
*
|
*
|
||||||
|
@ -220,20 +213,20 @@ class Services_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function get_value($field_name, $service_id) {
|
public function get_value($field_name, $service_id) {
|
||||||
if (!is_numeric($service_id)) {
|
if (!is_numeric($service_id)) {
|
||||||
throw new Exception('Invalid argument provided as $service_id : ' . $service_id);
|
throw new Exception('Invalid argument provided as $service_id: ' . $service_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($field_name)) {
|
if (!is_string($field_name)) {
|
||||||
throw new Exception('$field_name argument is not a string : ' . $field_name);
|
throw new Exception('$field_name argument is not a string: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_services', array('id' => $service_id))->num_rows() == 0) {
|
if ($this->db->get_where('ea_services', array('id' => $service_id))->num_rows() == 0) {
|
||||||
throw new Exception('The record with the $service_id argument does not exist in the database : ' . $service_id);
|
throw new Exception('The record with the $service_id argument does not exist in the database: ' . $service_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
$row_data = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
||||||
if (!isset($row_data[$field_name])) {
|
if (!isset($row_data[$field_name])) {
|
||||||
throw new Exception('The given $field_name argument does not exist in the database : ' . $field_name);
|
throw new Exception('The given $field_name argument does not exist in the database: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$setting = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
$setting = $this->db->get_where('ea_services', array('id' => $service_id))->row_array();
|
||||||
|
|
|
@ -17,13 +17,6 @@
|
||||||
* @package Models
|
* @package Models
|
||||||
*/
|
*/
|
||||||
class Settings_Model extends CI_Model {
|
class Settings_Model extends CI_Model {
|
||||||
/**
|
|
||||||
* Class Constructor
|
|
||||||
*/
|
|
||||||
function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get setting value from database.
|
* Get setting value from database.
|
||||||
*
|
*
|
||||||
|
@ -37,11 +30,11 @@ class Settings_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function get_setting($name) {
|
public function get_setting($name) {
|
||||||
if (!is_string($name)) { // Check argument type.
|
if (!is_string($name)) { // Check argument type.
|
||||||
throw new Exception('$name argument is not a string : ' . $name);
|
throw new Exception('$name argument is not a string: ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) { // Check if setting exists in db.
|
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) { // Check if setting exists in db.
|
||||||
throw new Exception('$name setting does not exist in database : ' . $name);
|
throw new Exception('$name setting does not exist in database: ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
||||||
|
@ -63,7 +56,7 @@ class Settings_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function set_setting($name, $value) {
|
public function set_setting($name, $value) {
|
||||||
if (!is_string($name)) {
|
if (!is_string($name)) {
|
||||||
throw new Exception('$name argument is not a string : ' . $name);
|
throw new Exception('$name argument is not a string: ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
$query = $this->db->get_where('ea_settings', array('name' => $name));
|
||||||
|
@ -99,7 +92,7 @@ class Settings_Model extends CI_Model {
|
||||||
*/
|
*/
|
||||||
public function remove_setting($name) {
|
public function remove_setting($name) {
|
||||||
if (!is_string($name)) {
|
if (!is_string($name)) {
|
||||||
throw new Exception('$name is not a string : ' . $name);
|
throw new Exception('$name is not a string: ' . $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) {
|
if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) {
|
||||||
|
|
|
@ -20,18 +20,13 @@
|
||||||
*/
|
*/
|
||||||
class User_Model extends CI_Model {
|
class User_Model extends CI_Model {
|
||||||
/**
|
/**
|
||||||
* Class Constructor
|
* Returns the user from the database for the "settings" page.
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the user settings from the database.
|
|
||||||
*
|
*
|
||||||
* @param numeric $user_id User record id of which the settings will be returned.
|
* @param numeric $user_id User record id.
|
||||||
*
|
*
|
||||||
* @return array Returns an array with user settings.
|
* @return array Returns an array with user data.
|
||||||
|
*
|
||||||
|
* @todo Refactor this method as it does not do as it states.
|
||||||
*/
|
*/
|
||||||
public function get_settings($user_id) {
|
public function get_settings($user_id) {
|
||||||
$user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array();
|
$user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array();
|
||||||
|
@ -41,11 +36,13 @@ class User_Model extends CI_Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method saves the user settings into the database.
|
* This method saves the user record into the database (used in backend settings page).
|
||||||
*
|
*
|
||||||
* @param array $user Contains the current users settings.
|
* @param array $user Contains the current users data.
|
||||||
*
|
*
|
||||||
* @return bool Returns the operation result.
|
* @return bool Returns the operation result.
|
||||||
|
*
|
||||||
|
* @todo Refactor this method as it does not do as it states.
|
||||||
*/
|
*/
|
||||||
public function save_settings($user) {
|
public function save_settings($user) {
|
||||||
$user_settings = $user['settings'];
|
$user_settings = $user['settings'];
|
||||||
|
|
Loading…
Reference in a new issue