Added the find method to controllers

This commit is contained in:
Alex Tselegidis 2021-12-14 07:18:46 +01:00
parent dd89afbfd7
commit 6376fea885
8 changed files with 195 additions and 3 deletions

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}