From 6376fea885977648f03753e9eeb70330cc44ab87 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Tue, 14 Dec 2021 07:18:46 +0100 Subject: [PATCH] Added the find method to controllers --- application/controllers/Admins.php | 30 +++++++++++++++++-- application/controllers/Appointments.php | 24 +++++++++++++++ application/controllers/Customers.php | 24 +++++++++++++++ application/controllers/Providers.php | 24 +++++++++++++++ application/controllers/Secretaries.php | 24 +++++++++++++++ .../controllers/Service_categories.php | 24 +++++++++++++++ application/controllers/Services.php | 24 +++++++++++++++ application/controllers/Unavailabilities.php | 24 +++++++++++++++ 8 files changed, 195 insertions(+), 3 deletions(-) diff --git a/application/controllers/Admins.php b/application/controllers/Admins.php index b9e1d5f7..67c6c196 100644 --- a/application/controllers/Admins.php +++ b/application/controllers/Admins.php @@ -92,7 +92,7 @@ class Admins extends EA_Controller { } /** - * Create a admin. + * Create an admin. */ public function create() { @@ -119,7 +119,7 @@ class Admins extends EA_Controller { } /** - * Update a admin. + * Update an admin. */ public function update() { @@ -146,7 +146,7 @@ class Admins extends EA_Controller { } /** - * Remove a admin. + * Remove an admin. */ public function destroy() { @@ -170,4 +170,28 @@ class Admins extends EA_Controller { json_exception($e); } } + + /** + * Find an admin. + */ + public function find() + { + try + { + if (cannot('delete', PRIV_USERS)) + { + show_error('Forbidden', 403); + } + + $admin_id = request('admin_id'); + + $admin = $this->admins_model->find($admin_id); + + json_response($admin); + } + catch (Throwable $e) + { + json_exception($e); + } + } } diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index 9760ae5a..c348d4dd 100644 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -157,4 +157,28 @@ class Appointments extends EA_Controller { json_exception($e); } } + + /** + * Find an appointment. + */ + public function find() + { + try + { + if (cannot('delete', PRIV_APPOINTMENTS)) + { + show_error('Forbidden', 403); + } + + $appointment_id = request('appointment_id'); + + $appointment = $this->appointments_model->find($appointment_id); + + json_response($appointment); + } + catch (Throwable $e) + { + json_exception($e); + } + } } diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php index 8c65cf75..003e0d97 100644 --- a/application/controllers/Customers.php +++ b/application/controllers/Customers.php @@ -186,4 +186,28 @@ class Customers extends EA_Controller { json_exception($e); } } + + /** + * Find a customer. + */ + public function find() + { + try + { + if (cannot('delete', PRIV_USERS)) + { + show_error('Forbidden', 403); + } + + $customer_id = request('customer_id'); + + $customer = $this->customers_model->find($customer_id); + + json_response($customer); + } + catch (Throwable $e) + { + json_exception($e); + } + } } diff --git a/application/controllers/Providers.php b/application/controllers/Providers.php index e7f1684e..79364944 100644 --- a/application/controllers/Providers.php +++ b/application/controllers/Providers.php @@ -172,4 +172,28 @@ class Providers extends EA_Controller { json_exception($e); } } + + /** + * Find a provider. + */ + public function find() + { + try + { + if (cannot('delete', PRIV_USERS)) + { + show_error('Forbidden', 403); + } + + $provider_id = request('provider_id'); + + $provider = $this->providers_model->find($provider_id); + + json_response($provider); + } + catch (Throwable $e) + { + json_exception($e); + } + } } diff --git a/application/controllers/Secretaries.php b/application/controllers/Secretaries.php index d04f722b..df0d9975 100644 --- a/application/controllers/Secretaries.php +++ b/application/controllers/Secretaries.php @@ -172,4 +172,28 @@ class Secretaries extends EA_Controller { json_exception($e); } } + + /** + * Find a secretary. + */ + public function find() + { + try + { + if (cannot('delete', PRIV_USERS)) + { + show_error('Forbidden', 403); + } + + $secretary_id = request('secretary_id'); + + $secretary = $this->secretaries_model->find($secretary_id); + + json_response($secretary); + } + catch (Throwable $e) + { + json_exception($e); + } + } } diff --git a/application/controllers/Service_categories.php b/application/controllers/Service_categories.php index a718a8a9..202ad194 100644 --- a/application/controllers/Service_categories.php +++ b/application/controllers/Service_categories.php @@ -170,4 +170,28 @@ class Service_categories extends EA_Controller { json_exception($e); } } + + /** + * Find a service category. + */ + public function find() + { + try + { + if (cannot('delete', PRIV_SERVICES)) + { + show_error('Forbidden', 403); + } + + $category_id = request('category_id'); + + $category = $this->service_categories_model->find($category_id); + + json_response($category); + } + catch (Throwable $e) + { + json_exception($e); + } + } } diff --git a/application/controllers/Services.php b/application/controllers/Services.php index fa2b27f6..eaed4f52 100644 --- a/application/controllers/Services.php +++ b/application/controllers/Services.php @@ -170,4 +170,28 @@ class Services extends EA_Controller { json_exception($e); } } + + /** + * Find a service. + */ + public function find() + { + try + { + if (cannot('delete', PRIV_SERVICES)) + { + show_error('Forbidden', 403); + } + + $service_id = request('service_id'); + + $service = $this->services_model->find($service_id); + + json_response($service); + } + catch (Throwable $e) + { + json_exception($e); + } + } } diff --git a/application/controllers/Unavailabilities.php b/application/controllers/Unavailabilities.php index dffa6b45..7e7f257c 100644 --- a/application/controllers/Unavailabilities.php +++ b/application/controllers/Unavailabilities.php @@ -142,4 +142,28 @@ class Unavailabilities extends EA_Controller { json_exception($e); } } + + /** + * Find an unavailability. + */ + public function find() + { + try + { + if (cannot('delete', 'users')) + { + show_error('Forbidden', 403); + } + + $unavailability_id = request('unavailability_id'); + + $unavailability = $this->unavailabilities_model->find($unavailability_id); + + json_response($unavailability); + } + catch (Throwable $e) + { + json_exception($e); + } + } }