diff --git a/application/models/Service_categories_model.php b/application/models/Service_categories_model.php index 0340d612..b0fc1c3f 100644 --- a/application/models/Service_categories_model.php +++ b/application/models/Service_categories_model.php @@ -134,39 +134,25 @@ class Service_categories_model extends EA_Model { * Remove an existing service-category from the database. * * @param int $service_category_id Service-Category ID. - * @param bool $force_delete Override soft delete. * * @throws RuntimeException */ - public function delete(int $service_category_id, bool $force_delete = FALSE) + public function delete(int $service_category_id): void { - if ($force_delete) - { - $this->db->delete('service_categories', ['id' => $service_category_id]); - } - else - { - $this->db->update('service_categories', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $service_category_id]); - } + $this->db->delete('service_categories', ['id' => $service_category_id]); } /** * Get a specific service-category from the database. * * @param int $service_category_id The ID of the record to be returned. - * @param bool $with_trashed * * @return array Returns an array with the service-category data. * * @throws InvalidArgumentException */ - public function find(int $service_category_id, bool $with_trashed = FALSE): array + public function find(int $service_category_id): array { - if ( ! $with_trashed) - { - $this->db->where('delete_datetime IS NULL'); - } - $service_category = $this->db->get_where('service_categories', ['id' => $service_category_id])->row_array(); if ( ! $service_category) @@ -229,11 +215,10 @@ class Service_categories_model extends EA_Model { * @param int|null $limit Record limit. * @param int|null $offset Record offset. * @param string|null $order_by Order by. - * @param bool $with_trashed * * @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) { @@ -245,11 +230,6 @@ class Service_categories_model extends EA_Model { $this->db->order_by($order_by); } - if ( ! $with_trashed) - { - $this->db->where('delete_datetime IS NULL'); - } - $service_categories = $this->db->get('service_categories', $limit, $offset)->result_array(); foreach ($service_categories as &$service_category) @@ -277,17 +257,11 @@ class Service_categories_model extends EA_Model { * @param int|null $limit Record limit. * @param int|null $offset Record offset. * @param string|null $order_by Order by. - * @param bool $with_trashed * * @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'); - } - $service_categories = $this ->db ->select() diff --git a/application/models/Services_model.php b/application/models/Services_model.php index 8d9ec8a9..2d24633a 100644 --- a/application/models/Services_model.php +++ b/application/models/Services_model.php @@ -190,39 +190,25 @@ class Services_model extends EA_Model { * Remove an existing service from the database. * * @param int $service_id Service ID. - * @param bool $force_delete Override soft delete. * * @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]); - } - else - { - $this->db->update('services', ['delete_datetime' => date('Y-m-d H:i:s')], ['id' => $service_id]); - } + $this->db->delete('services', ['id' => $service_id]); } /** * Get a specific service from the database. * * @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. * * @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(); if ( ! $service) @@ -285,11 +271,10 @@ class Services_model extends EA_Model { * @param int|null $limit Record limit. * @param int|null $offset Record offset. * @param string|null $order_by Order by. - * @param bool $with_trashed * * @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) { @@ -301,11 +286,6 @@ class Services_model extends EA_Model { $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(); foreach ($services as &$service) @@ -337,7 +317,6 @@ class Services_model extends EA_Model { ->from('services') ->join('services_providers', 'services_providers.id_services = services.id', 'inner') ->join('service_categories', 'service_categories.id = services.id_service_categories', 'left') - ->where('services.delete_datetime IS NULL') ->order_by('name ASC') ->get() ->result_array(); @@ -367,17 +346,11 @@ class Services_model extends EA_Model { * @param int|null $limit Record limit. * @param int|null $offset Record offset. * @param string|null $order_by Order by. - * @param bool $with_trashed * * @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 ->db ->select() diff --git a/application/views/pages/service_categories.php b/application/views/pages/service_categories.php index b389497a..f699e8f7 100644 --- a/application/views/pages/service_categories.php +++ b/application/views/pages/service_categories.php @@ -73,7 +73,6 @@