forked from mirrors/easyappointments
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
|
||||
*/
|
||||
class Admins_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add (insert or update) an admin user record into database.
|
||||
*
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
* @package Models
|
||||
*/
|
||||
class Appointments_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_services'])) {
|
||||
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(
|
||||
|
@ -253,7 +246,7 @@ class Appointments_Model extends CI_Model {
|
|||
public function get_row($appointment_id) {
|
||||
if (!is_numeric($appointment_id)) {
|
||||
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',
|
||||
array('id' => $appointment_id))->row_array();
|
||||
|
@ -269,18 +262,18 @@ class Appointments_Model extends CI_Model {
|
|||
public function get_value($field_name, $appointment_id) {
|
||||
if (!is_numeric($appointment_id)) {
|
||||
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)) {
|
||||
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',
|
||||
array('id' => $appointment_id))->num_rows() == 0) {
|
||||
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',
|
||||
|
@ -288,7 +281,7 @@ class Appointments_Model extends CI_Model {
|
|||
|
||||
if (!isset($row_data[$field_name])) {
|
||||
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];
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
* @package Models
|
||||
*/
|
||||
class Customers_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a customer record to the database.
|
||||
*
|
||||
|
@ -148,7 +141,7 @@ class Customers_Model extends CI_Model {
|
|||
*/
|
||||
public function find_record_id($customer) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -191,13 +184,13 @@ class Customers_Model extends CI_Model {
|
|||
if (!isset($customer['last_name'])
|
||||
|| !isset($customer['email'])
|
||||
|| !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));
|
||||
}
|
||||
|
||||
// Validate email address
|
||||
if (!filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
throw new Exception('Invalid email address provided : '
|
||||
throw new Exception('Invalid email address provided: '
|
||||
. $customer['email']);
|
||||
}
|
||||
|
||||
|
@ -230,7 +223,7 @@ class Customers_Model extends CI_Model {
|
|||
*/
|
||||
public function delete($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();
|
||||
|
@ -266,25 +259,25 @@ class Customers_Model extends CI_Model {
|
|||
*/
|
||||
public function get_value($field_name, $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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if ($this->db->get_where('ea_users', array('id' => $customer_id))->num_rows() == 0) {
|
||||
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_array();
|
||||
if (!isset($row_data[$field_name])) {
|
||||
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();
|
||||
|
|
|
@ -45,13 +45,6 @@
|
|||
* @package Models
|
||||
*/
|
||||
class Providers_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add (insert - update) a service provider record.
|
||||
*
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
* @package Models
|
||||
*/
|
||||
class Roles_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the record id of a particular role.
|
||||
*
|
||||
|
|
|
@ -34,13 +34,6 @@
|
|||
* @package Models
|
||||
*/
|
||||
class Secretaries_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add (insert or update) a secretary user record into database.
|
||||
*
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
* @package Models
|
||||
*/
|
||||
class Services_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
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)) {
|
||||
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) {
|
||||
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();
|
||||
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();
|
||||
|
|
|
@ -17,13 +17,6 @@
|
|||
* @package Models
|
||||
*/
|
||||
class Settings_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get setting value from database.
|
||||
*
|
||||
|
@ -37,11 +30,11 @@ class Settings_Model extends CI_Model {
|
|||
*/
|
||||
public function get_setting($name) {
|
||||
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.
|
||||
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));
|
||||
|
@ -63,7 +56,7 @@ class Settings_Model extends CI_Model {
|
|||
*/
|
||||
public function set_setting($name, $value) {
|
||||
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));
|
||||
|
@ -99,7 +92,7 @@ class Settings_Model extends CI_Model {
|
|||
*/
|
||||
public function remove_setting($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) {
|
||||
|
|
|
@ -20,18 +20,13 @@
|
|||
*/
|
||||
class User_Model extends CI_Model {
|
||||
/**
|
||||
* Class Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user settings from the database.
|
||||
* Returns the user from the database for the "settings" page.
|
||||
*
|
||||
* @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) {
|
||||
$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.
|
||||
*
|
||||
* @todo Refactor this method as it does not do as it states.
|
||||
*/
|
||||
public function save_settings($user) {
|
||||
$user_settings = $user['settings'];
|
||||
|
|
Loading…
Reference in a new issue