Drop support for soft deletes in order to reduce the code complexity and data usage

This commit is contained in:
Alex Tselegidis 2023-10-19 16:25:45 +02:00
parent 1710d46b6d
commit cf19a90311
16 changed files with 198 additions and 474 deletions

View file

@ -157,6 +157,6 @@ class Accounts {
*/ */
public function does_account_exist(int $user_id): bool public function does_account_exist(int $user_id): bool
{ {
return $this->CI->users_model->query()->where(['id' => $user_id, 'delete_datetime' => NULL])->get()->num_rows() > 0; return $this->CI->users_model->query()->where(['id' => $user_id])->get()->num_rows() > 0;
} }
} }

View file

@ -12,6 +12,9 @@
* ---------------------------------------------------------------------------- */ * ---------------------------------------------------------------------------- */
class Migration_Add_timestamp_columns extends EA_Migration { class Migration_Add_timestamp_columns extends EA_Migration {
/**
* @var string[]
*/
protected $tables = [ protected $tables = [
'appointments', 'appointments',
'categories', 'categories',
@ -21,6 +24,7 @@ class Migration_Add_timestamp_columns extends EA_Migration {
'settings', 'settings',
'users' 'users'
]; ];
/** /**
* @var string[] * @var string[]
*/ */

View file

@ -0,0 +1,64 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) 2013 - 2020, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */
class Migration_Drop_delete_datetime_column_from_all_tables extends EA_Migration {
/**
* @var string[]
*/
protected $tables = [
'appointments',
'categories',
'consents',
'roles',
'services',
'settings',
'users',
'webhooks'
];
/**
* Upgrade method.
*/
public function up()
{
foreach ($this->tables as $table)
{
if ($this->db->field_exists('delete_datetime', $table))
{
$this->dbforge->drop_column($table, 'delete_datetime');
}
}
}
/**
* Downgrade method.
*/
public function down()
{
foreach ($this->tables as $table)
{
if ( ! $this->db->field_exists('delete_datetime', $table))
{
$fields = [
'delete_datetime' => [
'type' => 'DATETIME',
'null' => TRUE,
'after' => 'update_datetime',
]
];
$this->dbforge->add_column($table, $fields);
}
}
}
}

View file

@ -154,7 +154,6 @@ class Admins_model extends EA_Model {
->where('roles.slug', DB_SLUG_ADMIN) ->where('roles.slug', DB_SLUG_ADMIN)
->where('users.email', $admin['email']) ->where('users.email', $admin['email'])
->where('users.id !=', $admin_id) ->where('users.id !=', $admin_id)
->where('users.delete_datetime')
->get() ->get()
->num_rows(); ->num_rows();
@ -183,7 +182,7 @@ class Admins_model extends EA_Model {
->db ->db
->from('users') ->from('users')
->join('user_settings', 'user_settings.id_users = users.id', 'inner') ->join('user_settings', 'user_settings.id_users = users.id', 'inner')
->where(['username' => $username, 'delete_datetime' => NULL]) ->where(['username' => $username])
->get() ->get()
->num_rows() === 0; ->num_rows() === 0;
} }
@ -272,48 +271,34 @@ class Admins_model extends EA_Model {
* Remove an existing admin from the database. * Remove an existing admin from the database.
* *
* @param int $admin_id Admin ID. * @param int $admin_id Admin ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $admin_id, bool $force_delete = FALSE) public function delete(int $admin_id): void
{ {
$role_id = $this->get_admin_role_id(); $role_id = $this->get_admin_role_id();
$count = $this->db->get_where('users', ['id_roles' => $role_id, 'delete_datetime' => NULL])->num_rows(); $count = $this->db->get_where('users', ['id_roles' => $role_id])->num_rows();
if ($count <= 1) if ($count <= 1)
{ {
throw new RuntimeException('Record could not be deleted as the app requires at least one admin user.'); throw new RuntimeException('Record could not be deleted as the app requires at least one admin user.');
} }
if ($force_delete) $this->db->delete('users', ['id' => $admin_id]);
{
$this->db->delete('users', ['id' => $admin_id]);
}
else
{
$this->db->update('users', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $admin_id]);
}
} }
/** /**
* Get a specific admin from the database. * Get a specific admin from the database.
* *
* @param int $admin_id The ID of the record to be returned. * @param int $admin_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the admin data. * @return array Returns an array with the admin data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $admin_id, bool $with_trashed = FALSE): array public function find(int $admin_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$admin = $this->db->get_where('users', ['id' => $admin_id])->row_array(); $admin = $this->db->get_where('users', ['id' => $admin_id])->row_array();
if ( ! $admin) if ( ! $admin)
@ -384,11 +369,10 @@ class Admins_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of admins. * @return array Returns an array of admins.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_admin_role_id(); $role_id = $this->get_admin_role_id();
@ -402,11 +386,6 @@ class Admins_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$admins = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array(); $admins = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
foreach ($admins as &$admin) foreach ($admins as &$admin)
@ -525,19 +504,13 @@ class Admins_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of admins. * @return array Returns an array of admins.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_admin_role_id(); $role_id = $this->get_admin_role_id();
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$admins = $this $admins = $this
->db ->db
->select() ->select()

View file

@ -219,39 +219,25 @@ class Appointments_model extends EA_Model {
* Remove an existing appointment from the database. * Remove an existing appointment from the database.
* *
* @param int $appointment_id Appointment ID. * @param int $appointment_id Appointment ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $appointment_id, bool $force_delete = FALSE) public function delete(int $appointment_id): void
{ {
if ($force_delete) $this->db->delete('appointments', ['id' => $appointment_id]);
{
$this->db->delete('appointments', ['id' => $appointment_id]);
}
else
{
$this->db->update('appointments', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $appointment_id]);
}
} }
/** /**
* Get a specific appointment from the database. * Get a specific appointment from the database.
* *
* @param int $appointment_id The ID of the record to be returned. * @param int $appointment_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the appointment data. * @return array Returns an array with the appointment data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $appointment_id, bool $with_trashed = FALSE): array public function find(int $appointment_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$appointment = $this->db->get_where('appointments', ['id' => $appointment_id])->row_array(); $appointment = $this->db->get_where('appointments', ['id' => $appointment_id])->row_array();
if ( ! $appointment) if ( ! $appointment)
@ -314,11 +300,10 @@ class Appointments_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of appointments. * @return array Returns an array of appointments.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -330,11 +315,6 @@ class Appointments_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$appointments = $this->db->get_where('appointments', ['is_unavailability' => FALSE], $limit, $offset)->result_array(); $appointments = $this->db->get_where('appointments', ['is_unavailability' => FALSE], $limit, $offset)->result_array();
foreach ($appointments as &$appointment) foreach ($appointments as &$appointment)
@ -453,17 +433,11 @@ class Appointments_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of appointments. * @return array Returns an array of appointments.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('appointments.delete_datetime IS NULL');
}
$appointments = $this $appointments = $this
->db ->db
->select('appointments.*') ->select('appointments.*')

View file

@ -134,39 +134,25 @@ class Categories_model extends EA_Model {
* Remove an existing category from the database. * Remove an existing category from the database.
* *
* @param int $category_id Category ID. * @param int $category_id Category ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $category_id, bool $force_delete = FALSE) public function delete(int $category_id): void
{ {
if ($force_delete) $this->db->delete('categories', ['id' => $category_id]);
{
$this->db->delete('categories', ['id' => $category_id]);
}
else
{
$this->db->update('categories', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $category_id]);
}
} }
/** /**
* Get a specific category from the database. * Get a specific category from the database.
* *
* @param int $category_id The ID of the record to be returned. * @param int $category_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the category data. * @return array Returns an array with the category data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $category_id, bool $with_trashed = FALSE): array public function find(int $category_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$category = $this->db->get_where('categories', ['id' => $category_id])->row_array(); $category = $this->db->get_where('categories', ['id' => $category_id])->row_array();
if ( ! $category) if ( ! $category)
@ -229,11 +215,10 @@ class Categories_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of service categories. * @return array Returns an array of service categories.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -245,11 +230,6 @@ class Categories_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$categories = $this->db->get('categories', $limit, $offset)->result_array(); $categories = $this->db->get('categories', $limit, $offset)->result_array();
foreach ($categories as &$category) foreach ($categories as &$category)
@ -277,17 +257,11 @@ class Categories_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of service categories. * @return array Returns an array of service categories.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$categories = $this $categories = $this
->db ->db
->select() ->select()

View file

@ -115,37 +115,23 @@ class Consents_model extends EA_Model {
* Remove an existing consent from the database. * Remove an existing consent from the database.
* *
* @param int $consent_id Consent ID. * @param int $consent_id Consent ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $consent_id, bool $force_delete = FALSE) public function delete(int $consent_id): void
{ {
if ($force_delete) $this->db->delete('consents', ['id' => $consent_id]);
{
$this->db->delete('consents', ['id' => $consent_id]);
}
else
{
$this->db->update('consents', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $consent_id]);
}
} }
/** /**
* Get a specific consent from the database. * Get a specific consent from the database.
* *
* @param int $consent_id The ID of the record to be returned. * @param int $consent_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the consent data. * @return array Returns an array with the consent data.
*/ */
public function find(int $consent_id, bool $with_trashed = FALSE): array public function find(int $consent_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$consent = $this->db->get_where('consents', ['id' => $consent_id])->row_array(); $consent = $this->db->get_where('consents', ['id' => $consent_id])->row_array();
if ( ! $consent) if ( ! $consent)
@ -208,11 +194,10 @@ class Consents_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of consents. * @return array Returns an array of consents.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -224,10 +209,7 @@ class Consents_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$consents = $this->db->get('consents', $limit, $offset)->result_array(); $consents = $this->db->get('consents', $limit, $offset)->result_array();
@ -256,17 +238,11 @@ class Consents_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of consents. * @return array Returns an array of consents.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$consents = $this $consents = $this
->db ->db
->select() ->select()

View file

@ -131,7 +131,6 @@ class Customers_model extends EA_Model {
->select() ->select()
->from('users') ->from('users')
->join('roles', 'roles.id = users.id_roles', 'inner') ->join('roles', 'roles.id = users.id_roles', 'inner')
->where('users.delete_datetime')
->where('roles.slug', DB_SLUG_CUSTOMER) ->where('roles.slug', DB_SLUG_CUSTOMER)
->where('users.email', $customer['email']) ->where('users.email', $customer['email'])
->where('users.id !=', $customer_id) ->where('users.id !=', $customer_id)
@ -193,38 +192,23 @@ class Customers_model extends EA_Model {
* Remove an existing customer from the database. * Remove an existing customer from the database.
* *
* @param int $customer_id Customer ID. * @param int $customer_id Customer ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $customer_id, bool $force_delete = FALSE) public function delete(int $customer_id): void
{ {
if ($force_delete) $this->db->delete('users', ['id' => $customer_id]);
{
$this->db->delete('users', ['id' => $customer_id]);
}
else
{
$this->db->update('users', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $customer_id]);
$this->db->update('appointments', ['delete_datetime' => date('Y-m-d H:i:s')], ['id_users_customer' => $customer_id, 'delete_datetime' => NULL]);
}
} }
/** /**
* Get a specific customer from the database. * Get a specific customer from the database.
* *
* @param int $customer_id The ID of the record to be returned. * @param int $customer_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the customer data. * @return array Returns an array with the customer data.
*/ */
public function find(int $customer_id, bool $with_trashed = FALSE): array public function find(int $customer_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$customer = $this->db->get_where('users', ['id' => $customer_id])->row_array(); $customer = $this->db->get_where('users', ['id' => $customer_id])->row_array();
if ( ! $customer) if ( ! $customer)
@ -287,11 +271,10 @@ class Customers_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of customers. * @return array Returns an array of customers.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_customer_role_id(); $role_id = $this->get_customer_role_id();
@ -305,11 +288,6 @@ class Customers_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$customers = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array(); $customers = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
foreach ($customers as &$customer) foreach ($customers as &$customer)
@ -359,7 +337,6 @@ class Customers_model extends EA_Model {
->from('users') ->from('users')
->join('roles', 'roles.id = users.id_roles', 'inner') ->join('roles', 'roles.id = users.id_roles', 'inner')
->where('users.email', $customer['email']) ->where('users.email', $customer['email'])
->where('users.delete_datetime')
->where('roles.slug', DB_SLUG_CUSTOMER) ->where('roles.slug', DB_SLUG_CUSTOMER)
->get() ->get()
->num_rows(); ->num_rows();
@ -389,7 +366,6 @@ class Customers_model extends EA_Model {
->from('users') ->from('users')
->join('roles', 'roles.id = users.id_roles', 'inner') ->join('roles', 'roles.id = users.id_roles', 'inner')
->where('users.email', $customer['email']) ->where('users.email', $customer['email'])
->where('users.delete_datetime')
->where('roles.slug', DB_SLUG_CUSTOMER) ->where('roles.slug', DB_SLUG_CUSTOMER)
->get() ->get()
->row_array(); ->row_array();
@ -421,19 +397,13 @@ class Customers_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of customers. * @return array Returns an array of customers.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_customer_role_id(); $role_id = $this->get_customer_role_id();
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$customers = $this $customers = $this
->db ->db
->select() ->select()

View file

@ -169,7 +169,6 @@ class Providers_model extends EA_Model {
->where('roles.slug', DB_SLUG_PROVIDER) ->where('roles.slug', DB_SLUG_PROVIDER)
->where('users.email', $provider['email']) ->where('users.email', $provider['email'])
->where('users.id !=', $provider_id) ->where('users.id !=', $provider_id)
->where('users.delete_datetime')
->get() ->get()
->num_rows(); ->num_rows();
@ -198,7 +197,7 @@ class Providers_model extends EA_Model {
->db ->db
->from('users') ->from('users')
->join('user_settings', 'user_settings.id_users = users.id', 'inner') ->join('user_settings', 'user_settings.id_users = users.id', 'inner')
->where(['username' => $username, 'delete_datetime' => NULL]) ->where(['username' => $username])
->get() ->get()
->num_rows() === 0; ->num_rows() === 0;
} }
@ -291,39 +290,25 @@ class Providers_model extends EA_Model {
* Remove an existing provider from the database. * Remove an existing provider from the database.
* *
* @param int $provider_id Provider ID. * @param int $provider_id Provider ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $provider_id, bool $force_delete = FALSE) public function delete(int $provider_id): void
{ {
if ($force_delete) $this->db->delete('users', ['id' => $provider_id]);
{
$this->db->delete('users', ['id' => $provider_id]);
}
else
{
$this->db->update('users', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $provider_id]);
}
} }
/** /**
* Get a specific provider from the database. * Get a specific provider from the database.
* *
* @param int $provider_id The ID of the record to be returned. * @param int $provider_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the provider data. * @return array Returns an array with the provider data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $provider_id, bool $with_trashed = FALSE): array public function find(int $provider_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$provider = $this->db->get_where('users', ['id' => $provider_id])->row_array(); $provider = $this->db->get_where('users', ['id' => $provider_id])->row_array();
if ( ! $provider) if ( ! $provider)
@ -403,11 +388,10 @@ class Providers_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of providers. * @return array Returns an array of providers.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_provider_role_id(); $role_id = $this->get_provider_role_id();
@ -421,10 +405,6 @@ class Providers_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$providers = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array(); $providers = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
@ -610,7 +590,7 @@ class Providers_model extends EA_Model {
// Store the working plan exception. // Store the working plan exception.
$working_plan_exceptions = json_decode($provider['settings']['working_plan_exceptions'], TRUE); $working_plan_exceptions = json_decode($provider['settings']['working_plan_exceptions'], TRUE);
if ( is_array($working_plan_exception) && ! isset($working_plan_exception['breaks'])) if (is_array($working_plan_exception) && ! isset($working_plan_exception['breaks']))
{ {
$working_plan_exception['breaks'] = []; $working_plan_exception['breaks'] = [];
} }
@ -668,7 +648,6 @@ class Providers_model extends EA_Model {
->from('users') ->from('users')
->join('roles', 'roles.id = users.id_roles', 'inner') ->join('roles', 'roles.id = users.id_roles', 'inner')
->where('roles.slug', DB_SLUG_PROVIDER) ->where('roles.slug', DB_SLUG_PROVIDER)
->where('users.delete_datetime IS NULL')
->order_by('first_name ASC, last_name ASC, email ASC') ->order_by('first_name ASC, last_name ASC, email ASC')
->get() ->get()
->result_array(); ->result_array();
@ -716,19 +695,13 @@ class Providers_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of providers. * @return array Returns an array of providers.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_provider_role_id(); $role_id = $this->get_provider_role_id();
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$providers = $this $providers = $this
->db ->db
->select() ->select()

View file

@ -132,39 +132,25 @@ class Roles_model extends EA_Model {
* Remove an existing role from the database. * Remove an existing role from the database.
* *
* @param int $role_id Role ID. * @param int $role_id Role ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $role_id, bool $force_delete = FALSE) public function delete(int $role_id): void
{ {
if ($force_delete) $this->db->delete('roles', ['id' => $role_id]);
{
$this->db->delete('roles', ['id' => $role_id]);
}
else
{
$this->db->update('roles', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $role_id]);
}
} }
/** /**
* Get a specific role from the database. * Get a specific role from the database.
* *
* @param int $role_id The ID of the record to be returned. * @param int $role_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the role data. * @return array Returns an array with the role data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $role_id, bool $with_trashed = FALSE): array public function find(int $role_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$role = $this->db->get_where('roles', ['id' => $role_id])->row_array(); $role = $this->db->get_where('roles', ['id' => $role_id])->row_array();
if ( ! $role) if ( ! $role)
@ -227,11 +213,10 @@ class Roles_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of roles. * @return array Returns an array of roles.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -243,11 +228,6 @@ class Roles_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$roles = $this->db->get('roles', $limit, $offset)->result_array(); $roles = $this->db->get('roles', $limit, $offset)->result_array();
foreach ($roles as &$role) foreach ($roles as &$role)
@ -343,17 +323,11 @@ class Roles_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of roles. * @return array Returns an array of roles.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$roles = $this $roles = $this
->db ->db
->select() ->select()

View file

@ -167,7 +167,6 @@ class Secretaries_model extends EA_Model {
->where('roles.slug', DB_SLUG_SECRETARY) ->where('roles.slug', DB_SLUG_SECRETARY)
->where('users.email', $secretary['email']) ->where('users.email', $secretary['email'])
->where('users.id !=', $secretary_id) ->where('users.id !=', $secretary_id)
->where('users.delete_datetime')
->get() ->get()
->num_rows(); ->num_rows();
@ -196,7 +195,7 @@ class Secretaries_model extends EA_Model {
->db ->db
->from('users') ->from('users')
->join('user_settings', 'user_settings.id_users = users.id', 'inner') ->join('user_settings', 'user_settings.id_users = users.id', 'inner')
->where(['username' => $username, 'delete_datetime' => NULL]) ->where(['username' => $username])
->get() ->get()
->num_rows() === 0; ->num_rows() === 0;
} }
@ -290,39 +289,25 @@ class Secretaries_model extends EA_Model {
* Remove an existing secretary from the database. * Remove an existing secretary from the database.
* *
* @param int $secretary_id Provider ID. * @param int $secretary_id Provider ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $secretary_id, bool $force_delete = FALSE) public function delete(int $secretary_id): void
{ {
if ($force_delete) $this->db->delete('users', ['id' => $secretary_id]);
{
$this->db->delete('users', ['id' => $secretary_id]);
}
else
{
$this->db->update('users', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $secretary_id]);
}
} }
/** /**
* Get a specific secretary from the database. * Get a specific secretary from the database.
* *
* @param int $secretary_id The ID of the record to be returned. * @param int $secretary_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the secretary data. * @return array Returns an array with the secretary data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $secretary_id, bool $with_trashed = FALSE): array public function find(int $secretary_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$secretary = $this->db->get_where('users', ['id' => $secretary_id])->row_array(); $secretary = $this->db->get_where('users', ['id' => $secretary_id])->row_array();
if ( ! $secretary) if ( ! $secretary)
@ -398,11 +383,10 @@ class Secretaries_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of secretaries. * @return array Returns an array of secretaries.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_secretary_role_id(); $role_id = $this->get_secretary_role_id();
@ -416,11 +400,6 @@ class Secretaries_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$secretaries = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array(); $secretaries = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array();
foreach ($secretaries as &$secretary) foreach ($secretaries as &$secretary)
@ -568,19 +547,13 @@ class Secretaries_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of secretaries. * @return array Returns an array of secretaries.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
$role_id = $this->get_secretary_role_id(); $role_id = $this->get_secretary_role_id();
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$secretaries = $this $secretaries = $this
->db ->db
->select() ->select()

View file

@ -190,39 +190,25 @@ class Services_model extends EA_Model {
* Remove an existing service from the database. * Remove an existing service from the database.
* *
* @param int $service_id Service ID. * @param int $service_id Service ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $service_id, bool $force_delete = FALSE) public function delete(int $service_id): void
{ {
if ($force_delete) $this->db->delete('services', ['id' => $service_id]);
{
$this->db->delete('services', ['id' => $service_id]);
}
else
{
$this->db->update('services', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $service_id]);
}
} }
/** /**
* Get a specific service from the database. * Get a specific service from the database.
* *
* @param int $service_id The ID of the record to be returned. * @param int $service_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the service data. * @return array Returns an array with the service data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $service_id, bool $with_trashed = FALSE): array public function find(int $service_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$service = $this->db->get_where('services', ['id' => $service_id])->row_array(); $service = $this->db->get_where('services', ['id' => $service_id])->row_array();
if ( ! $service) if ( ! $service)
@ -285,11 +271,10 @@ class Services_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of services. * @return array Returns an array of services.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -301,11 +286,6 @@ class Services_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$services = $this->db->get('services', $limit, $offset)->result_array(); $services = $this->db->get('services', $limit, $offset)->result_array();
foreach ($services as &$service) foreach ($services as &$service)
@ -337,7 +317,6 @@ class Services_model extends EA_Model {
->from('services') ->from('services')
->join('services_providers', 'services_providers.id_services = services.id', 'inner') ->join('services_providers', 'services_providers.id_services = services.id', 'inner')
->join('categories', 'categories.id = services.id_categories', 'left') ->join('categories', 'categories.id = services.id_categories', 'left')
->where('services.delete_datetime IS NULL')
->order_by('name ASC') ->order_by('name ASC')
->get() ->get()
->result_array(); ->result_array();
@ -367,17 +346,11 @@ class Services_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of services. * @return array Returns an array of services.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$services = $this $services = $this
->db ->db
->select() ->select()

View file

@ -131,41 +131,27 @@ class Settings_model extends EA_Model {
/** /**
* Remove an existing setting from the database. * Remove an existing setting from the database.
*
* @param int $setting_id Setting ID. * @param int $setting_id Setting ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $setting_id, bool $force_delete = FALSE) public function delete(int $setting_id): void
{ {
if ($force_delete) $this->db->delete('settings', ['id' => $setting_id]);
{
$this->db->delete('settings', ['id' => $setting_id]);
}
else
{
$this->db->update('settings', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $setting_id]);
}
} }
/** /**
* Get a specific setting from the database. * Get a specific setting from the database.
* *
* @param int $setting_id The ID of the record to be returned. * @param int $setting_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the setting data. * @return array Returns an array with the setting data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $setting_id, bool $with_trashed = FALSE): array public function find(int $setting_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$setting = $this->db->get_where('settings', ['id' => $setting_id])->row_array(); $setting = $this->db->get_where('settings', ['id' => $setting_id])->row_array();
if ( ! $setting) if ( ! $setting)
@ -228,11 +214,10 @@ class Settings_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of settings. * @return array Returns an array of settings.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -244,11 +229,6 @@ class Settings_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$settings = $this->db->get('settings', $limit, $offset)->result_array(); $settings = $this->db->get('settings', $limit, $offset)->result_array();
foreach ($settings as &$setting) foreach ($settings as &$setting)
@ -276,17 +256,11 @@ class Settings_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of settings. * @return array Returns an array of settings.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$settings = $this $settings = $this
->db ->db
->select() ->select()

View file

@ -184,39 +184,25 @@ class Unavailabilities_model extends EA_Model {
* Remove an existing unavailability from the database. * Remove an existing unavailability from the database.
* *
* @param int $unavailability_id Unavailability ID. * @param int $unavailability_id Unavailability ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $unavailability_id, bool $force_delete = FALSE) public function delete(int $unavailability_id): void
{ {
if ($force_delete) $this->db->delete('appointments', ['id' => $unavailability_id]);
{
$this->db->delete('appointments', ['id' => $unavailability_id]);
}
else
{
$this->db->update('appointments', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $unavailability_id]);
}
} }
/** /**
* Get a specific unavailability from the database. * Get a specific unavailability from the database.
* *
* @param int $unavailability_id The ID of the record to be returned. * @param int $unavailability_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the unavailability data. * @return array Returns an array with the unavailability data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $unavailability_id, bool $with_trashed = FALSE): array public function find(int $unavailability_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$unavailability = $this->db->get_where('appointments', ['id' => $unavailability_id])->row_array(); $unavailability = $this->db->get_where('appointments', ['id' => $unavailability_id])->row_array();
if ( ! $unavailability) if ( ! $unavailability)
@ -279,11 +265,10 @@ class Unavailabilities_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of unavailabilities. * @return array Returns an array of unavailabilities.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -295,11 +280,6 @@ class Unavailabilities_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$unavailabilities = $this->db->get_where('appointments', ['is_unavailability' => TRUE], $limit, $offset)->result_array(); $unavailabilities = $this->db->get_where('appointments', ['is_unavailability' => TRUE], $limit, $offset)->result_array();
foreach ($unavailabilities as &$unavailability) foreach ($unavailabilities as &$unavailability)
@ -327,17 +307,11 @@ class Unavailabilities_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of unavailabilities. * @return array Returns an array of unavailabilities.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('appointments.delete_datetime IS NULL');
}
$unavailabilities = $this $unavailabilities = $this
->db ->db
->select() ->select()

View file

@ -176,39 +176,25 @@ class Users_model extends EA_Model {
* Remove an existing user from the database. * Remove an existing user from the database.
* *
* @param int $user_id User ID. * @param int $user_id User ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $user_id, bool $force_delete = FALSE) public function delete(int $user_id): void
{ {
if ($force_delete) $this->db->delete('users', ['id' => $user_id]);
{
$this->db->delete('users', ['id' => $user_id]);
}
else
{
$this->db->update('users', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $user_id]);
}
} }
/** /**
* Get a specific user from the database. * Get a specific user from the database.
* *
* @param int $user_id The ID of the record to be returned. * @param int $user_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the user data. * @return array Returns an array with the user data.
* *
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function find(int $user_id, bool $with_trashed = FALSE): array public function find(int $user_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$user = $this->db->get_where('users', ['id' => $user_id])->row_array(); $user = $this->db->get_where('users', ['id' => $user_id])->row_array();
if ( ! $user) if ( ! $user)
@ -279,11 +265,10 @@ class Users_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of users. * @return array Returns an array of users.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -295,11 +280,6 @@ class Users_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$users = $this->db->get('users', $limit, $offset)->result_array(); $users = $this->db->get('users', $limit, $offset)->result_array();
foreach ($users as &$user) foreach ($users as &$user)
@ -399,17 +379,11 @@ class Users_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of settings. * @return array Returns an array of settings.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$users = $this $users = $this
->db ->db
->select() ->select()

View file

@ -133,37 +133,23 @@ class Webhooks_model extends EA_Model {
* Remove an existing webhook from the database. * Remove an existing webhook from the database.
* *
* @param int $webhook_id Webhook ID. * @param int $webhook_id Webhook ID.
* @param bool $force_delete Override soft delete.
* *
* @throws RuntimeException * @throws RuntimeException
*/ */
public function delete(int $webhook_id, bool $force_delete = FALSE) public function delete(int $webhook_id): void
{ {
if ($force_delete) $this->db->delete('webhooks', ['id' => $webhook_id]);
{
$this->db->delete('webhooks', ['id' => $webhook_id]);
}
else
{
$this->db->update('webhooks', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $webhook_id]);
}
} }
/** /**
* Get a specific webhook from the database. * Get a specific webhook from the database.
* *
* @param int $webhook_id The ID of the record to be returned. * @param int $webhook_id The ID of the record to be returned.
* @param bool $with_trashed
* *
* @return array Returns an array with the webhook data. * @return array Returns an array with the webhook data.
*/ */
public function find(int $webhook_id, bool $with_trashed = FALSE): array public function find(int $webhook_id): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$webhook = $this->db->get_where('webhooks', ['id' => $webhook_id])->row_array(); $webhook = $this->db->get_where('webhooks', ['id' => $webhook_id])->row_array();
if ( ! $webhook) if ( ! $webhook)
@ -226,11 +212,10 @@ class Webhooks_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of webhooks. * @return array Returns an array of webhooks.
*/ */
public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ($where !== NULL) if ($where !== NULL)
{ {
@ -242,11 +227,6 @@ class Webhooks_model extends EA_Model {
$this->db->order_by($order_by); $this->db->order_by($order_by);
} }
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$webhooks = $this->db->get('webhooks', $limit, $offset)->result_array(); $webhooks = $this->db->get('webhooks', $limit, $offset)->result_array();
foreach ($webhooks as &$webhook) foreach ($webhooks as &$webhook)
@ -274,17 +254,11 @@ class Webhooks_model extends EA_Model {
* @param int|null $limit Record limit. * @param int|null $limit Record limit.
* @param int|null $offset Record offset. * @param int|null $offset Record offset.
* @param string|null $order_by Order by. * @param string|null $order_by Order by.
* @param bool $with_trashed
* *
* @return array Returns an array of webhooks. * @return array Returns an array of webhooks.
*/ */
public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL, bool $with_trashed = FALSE): array public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array
{ {
if ( ! $with_trashed)
{
$this->db->where('delete_datetime IS NULL');
}
$webhooks = $this $webhooks = $this
->db ->db
->select() ->select()