mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-12-03 21:32:22 +03:00
Hook the optional field checks to all CRUD controllers
This commit is contained in:
parent
99cf4c8da2
commit
ca664294e9
12 changed files with 106 additions and 5 deletions
|
@ -36,8 +36,17 @@ class Account extends EA_Controller
|
||||||
'language',
|
'language',
|
||||||
'settings',
|
'settings',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_user_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
public array $allowed_user_setting_fields = ['username', 'password', 'notifications', 'calendar_view'];
|
public array $allowed_user_setting_fields = ['username', 'password', 'notifications', 'calendar_view'];
|
||||||
|
|
||||||
|
public array $optional_user_setting_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account constructor.
|
* Account constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -110,8 +119,12 @@ class Account extends EA_Controller
|
||||||
|
|
||||||
$this->users_model->only($account, $this->allowed_user_fields);
|
$this->users_model->only($account, $this->allowed_user_fields);
|
||||||
|
|
||||||
|
$this->users_model->optional($account, $this->optional_user_fields);
|
||||||
|
|
||||||
$this->users_model->only($account['settings'], $this->allowed_user_setting_fields);
|
$this->users_model->only($account['settings'], $this->allowed_user_setting_fields);
|
||||||
|
|
||||||
|
$this->users_model->optional($account['settings'], $this->optional_user_setting_fields);
|
||||||
|
|
||||||
if (empty($account['password'])) {
|
if (empty($account['password'])) {
|
||||||
unset($account['password']);
|
unset($account['password']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,8 +38,16 @@ class Admins extends EA_Controller
|
||||||
'settings',
|
'settings',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_admin_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
public array $allowed_admin_setting_fields = ['username', 'password', 'notifications', 'calendar_view'];
|
public array $allowed_admin_setting_fields = ['username', 'password', 'notifications', 'calendar_view'];
|
||||||
|
|
||||||
|
public array $optional_admin_settings_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admins constructor.
|
* Admins constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -139,8 +147,12 @@ class Admins extends EA_Controller
|
||||||
|
|
||||||
$this->admins_model->only($admin, $this->allowed_admin_fields);
|
$this->admins_model->only($admin, $this->allowed_admin_fields);
|
||||||
|
|
||||||
|
$this->admins_model->optional($admin, $this->optional_admin_fields);
|
||||||
|
|
||||||
$this->admins_model->only($admin['settings'], $this->allowed_admin_setting_fields);
|
$this->admins_model->only($admin['settings'], $this->allowed_admin_setting_fields);
|
||||||
|
|
||||||
|
$this->admins_model->optional($admin['settings'], $this->optional_admin_setting_fields);
|
||||||
|
|
||||||
$admin_id = $this->admins_model->save($admin);
|
$admin_id = $this->admins_model->save($admin);
|
||||||
|
|
||||||
$admin = $this->admins_model->find($admin_id);
|
$admin = $this->admins_model->find($admin_id);
|
||||||
|
|
|
@ -37,6 +37,10 @@ class Appointments extends EA_Controller
|
||||||
'id_services',
|
'id_services',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_appointment_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Appointments constructor.
|
* Appointments constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -104,6 +108,8 @@ class Appointments extends EA_Controller
|
||||||
|
|
||||||
$this->appointments_model->only($appointment, $this->allowed_appointment_fields);
|
$this->appointments_model->only($appointment, $this->allowed_appointment_fields);
|
||||||
|
|
||||||
|
$this->appointments_model->optional($appointment, $this->optional_appointment_fields);
|
||||||
|
|
||||||
$appointment_id = $this->appointments_model->save($appointment);
|
$appointment_id = $this->appointments_model->save($appointment);
|
||||||
|
|
||||||
$appointment = $this->appointments_model->find($appointment);
|
$appointment = $this->appointments_model->find($appointment);
|
||||||
|
@ -153,6 +159,8 @@ class Appointments extends EA_Controller
|
||||||
|
|
||||||
$this->appointments_model->only($appointment, $this->allowed_appointment_fields);
|
$this->appointments_model->only($appointment, $this->allowed_appointment_fields);
|
||||||
|
|
||||||
|
$this->appointments_model->optional($appointment, $this->optional_appointment_fields);
|
||||||
|
|
||||||
$appointment_id = $this->appointments_model->save($appointment);
|
$appointment_id = $this->appointments_model->save($appointment);
|
||||||
|
|
||||||
json_response([
|
json_response([
|
||||||
|
|
|
@ -22,6 +22,10 @@ class Blocked_periods extends EA_Controller
|
||||||
{
|
{
|
||||||
public array $allowed_blocked_period_fields = ['id', 'name', 'start_datetime', 'end_datetime', 'notes'];
|
public array $allowed_blocked_period_fields = ['id', 'name', 'start_datetime', 'end_datetime', 'notes'];
|
||||||
|
|
||||||
|
public array $optional_blocked_period_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Blocked_periods constructor.
|
* Blocked_periods constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -120,6 +124,8 @@ class Blocked_periods extends EA_Controller
|
||||||
|
|
||||||
$this->blocked_periods_model->only($blocked_period, $this->allowed_blocked_period_fields);
|
$this->blocked_periods_model->only($blocked_period, $this->allowed_blocked_period_fields);
|
||||||
|
|
||||||
|
$this->blocked_periods_model->optional($blocked_period, $this->optional_blocked_period_fields);
|
||||||
|
|
||||||
$blocked_period_id = $this->blocked_periods_model->save($blocked_period);
|
$blocked_period_id = $this->blocked_periods_model->save($blocked_period);
|
||||||
|
|
||||||
$blocked_period = $this->blocked_periods_model->find($blocked_period_id);
|
$blocked_period = $this->blocked_periods_model->find($blocked_period_id);
|
||||||
|
@ -169,6 +175,8 @@ class Blocked_periods extends EA_Controller
|
||||||
|
|
||||||
$this->blocked_periods_model->only($blocked_period, $this->allowed_blocked_period_fields);
|
$this->blocked_periods_model->only($blocked_period, $this->allowed_blocked_period_fields);
|
||||||
|
|
||||||
|
$this->blocked_periods_model->optional($blocked_period, $this->optional_blocked_period_fields);
|
||||||
|
|
||||||
$blocked_period_id = $this->blocked_periods_model->save($blocked_period);
|
$blocked_period_id = $this->blocked_periods_model->save($blocked_period);
|
||||||
|
|
||||||
$blocked_period = $this->blocked_periods_model->find($blocked_period_id);
|
$blocked_period = $this->blocked_periods_model->find($blocked_period_id);
|
||||||
|
|
|
@ -22,6 +22,10 @@ class Booking_settings extends EA_Controller
|
||||||
{
|
{
|
||||||
public array $allowed_setting_fields = ['id', 'name', 'value'];
|
public array $allowed_setting_fields = ['id', 'name', 'value'];
|
||||||
|
|
||||||
|
public array $optional_setting_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Booking_settings constructor.
|
* Booking_settings constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -104,6 +108,8 @@ class Booking_settings extends EA_Controller
|
||||||
|
|
||||||
$this->settings_model->only($setting, $this->allowed_setting_fields);
|
$this->settings_model->only($setting, $this->allowed_setting_fields);
|
||||||
|
|
||||||
|
$this->settings_model->optional($setting, $this->optional_setting_fields);
|
||||||
|
|
||||||
$this->settings_model->save($setting);
|
$this->settings_model->save($setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
*/
|
*/
|
||||||
class Business_settings extends EA_Controller
|
class Business_settings extends EA_Controller
|
||||||
{
|
{
|
||||||
|
public array $allowed_setting_fields = ['id', 'name', 'value'];
|
||||||
|
|
||||||
|
public array $optional_setting_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Business_logic constructor.
|
* Business_logic constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -102,7 +108,9 @@ class Business_settings extends EA_Controller
|
||||||
$setting['id'] = $existing_setting['id'];
|
$setting['id'] = $existing_setting['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->settings_model->only($setting, ['id', 'name', 'value']);
|
$this->settings_model->only($setting, $this->allowed_setting_fields);
|
||||||
|
|
||||||
|
$this->settings_model->optional($setting, $this->optional_setting_fields);
|
||||||
|
|
||||||
$this->settings_model->save($setting);
|
$this->settings_model->save($setting);
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,11 @@ class Calendar extends EA_Controller
|
||||||
'custom_field_4',
|
'custom_field_4',
|
||||||
'custom_field_5',
|
'custom_field_5',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_customer_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
public array $allowed_appointment_fields = [
|
public array $allowed_appointment_fields = [
|
||||||
'id',
|
'id',
|
||||||
'start_datetime',
|
'start_datetime',
|
||||||
|
@ -53,6 +58,10 @@ class Calendar extends EA_Controller
|
||||||
'id_services',
|
'id_services',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_appointment_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calendar constructor.
|
* Calendar constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -237,6 +246,8 @@ class Calendar extends EA_Controller
|
||||||
|
|
||||||
$this->customers_model->only($customer, $this->allowed_customer_fields);
|
$this->customers_model->only($customer, $this->allowed_customer_fields);
|
||||||
|
|
||||||
|
$this->customers_model->optional($customer, $this->optional_customer_fields);
|
||||||
|
|
||||||
$customer['id'] = $this->customers_model->save($customer);
|
$customer['id'] = $this->customers_model->save($customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,6 +277,8 @@ class Calendar extends EA_Controller
|
||||||
|
|
||||||
$this->appointments_model->only($appointment, $this->allowed_appointment_fields);
|
$this->appointments_model->only($appointment, $this->allowed_appointment_fields);
|
||||||
|
|
||||||
|
$this->appointments_model->optional($appointment, $this->optional_appointment_fields);
|
||||||
|
|
||||||
$appointment['id'] = $this->appointments_model->save($appointment);
|
$appointment['id'] = $this->appointments_model->save($appointment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,10 @@ class Customers extends EA_Controller
|
||||||
'ldap_dn',
|
'ldap_dn',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_customer_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Customers constructor.
|
* Customers constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -220,6 +224,8 @@ class Customers extends EA_Controller
|
||||||
|
|
||||||
$this->customers_model->only($customer, $this->allowed_customer_fields);
|
$this->customers_model->only($customer, $this->allowed_customer_fields);
|
||||||
|
|
||||||
|
$this->customers_model->optional($customer, $this->optional_customer_fields);
|
||||||
|
|
||||||
$customer_id = $this->customers_model->save($customer);
|
$customer_id = $this->customers_model->save($customer);
|
||||||
|
|
||||||
$customer = $this->customers_model->find($customer_id);
|
$customer = $this->customers_model->find($customer_id);
|
||||||
|
@ -255,6 +261,8 @@ class Customers extends EA_Controller
|
||||||
|
|
||||||
$this->customers_model->only($customer, $this->allowed_customer_fields);
|
$this->customers_model->only($customer, $this->allowed_customer_fields);
|
||||||
|
|
||||||
|
$this->customers_model->optional($customer, $this->optional_customer_fields);
|
||||||
|
|
||||||
$customer_id = $this->customers_model->save($customer);
|
$customer_id = $this->customers_model->save($customer);
|
||||||
|
|
||||||
$customer = $this->customers_model->find($customer_id);
|
$customer = $this->customers_model->find($customer_id);
|
||||||
|
|
|
@ -40,6 +40,11 @@ class Providers extends EA_Controller
|
||||||
'settings',
|
'settings',
|
||||||
'services',
|
'services',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_provider_fields = [
|
||||||
|
'services' => [],
|
||||||
|
];
|
||||||
|
|
||||||
public array $allowed_provider_setting_fields = [
|
public array $allowed_provider_setting_fields = [
|
||||||
'username',
|
'username',
|
||||||
'password',
|
'password',
|
||||||
|
@ -48,16 +53,14 @@ class Providers extends EA_Controller
|
||||||
'notifications',
|
'notifications',
|
||||||
'calendar_view',
|
'calendar_view',
|
||||||
];
|
];
|
||||||
public array $allowed_service_fields = ['id', 'name'];
|
|
||||||
public array $optional_provider_fields = [
|
|
||||||
'services' => [],
|
|
||||||
];
|
|
||||||
|
|
||||||
public array $optional_provider_setting_fields = [
|
public array $optional_provider_setting_fields = [
|
||||||
'working_plan' => null,
|
'working_plan' => null,
|
||||||
'working_plan_exceptions' => '{}',
|
'working_plan_exceptions' => '{}',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $allowed_service_fields = ['id', 'name'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Providers constructor.
|
* Providers constructor.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,6 +22,8 @@ class Service_categories extends EA_Controller
|
||||||
{
|
{
|
||||||
public array $allowed_service_category_fields = ['id', 'name', 'description'];
|
public array $allowed_service_category_fields = ['id', 'name', 'description'];
|
||||||
|
|
||||||
|
public array $optional_service_category_fields = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service-categories constructor.
|
* Service-categories constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -117,6 +119,8 @@ class Service_categories extends EA_Controller
|
||||||
|
|
||||||
$this->service_categories_model->only($service_category, $this->allowed_service_category_fields);
|
$this->service_categories_model->only($service_category, $this->allowed_service_category_fields);
|
||||||
|
|
||||||
|
$this->service_categories_model->optional($service_category, $this->optional_service_category_fields);
|
||||||
|
|
||||||
$service_category_id = $this->service_categories_model->save($service_category);
|
$service_category_id = $this->service_categories_model->save($service_category);
|
||||||
|
|
||||||
$service_category = $this->service_categories_model->find($service_category_id);
|
$service_category = $this->service_categories_model->find($service_category_id);
|
||||||
|
@ -166,6 +170,8 @@ class Service_categories extends EA_Controller
|
||||||
|
|
||||||
$this->service_categories_model->only($service_category, $this->allowed_service_category_fields);
|
$this->service_categories_model->only($service_category, $this->allowed_service_category_fields);
|
||||||
|
|
||||||
|
$this->service_categories_model->optional($service_category, $this->optional_service_category_fields);
|
||||||
|
|
||||||
$service_category_id = $this->service_categories_model->save($service_category);
|
$service_category_id = $this->service_categories_model->save($service_category);
|
||||||
|
|
||||||
$service_category = $this->service_categories_model->find($service_category_id);
|
$service_category = $this->service_categories_model->find($service_category_id);
|
||||||
|
|
|
@ -30,6 +30,10 @@ class Unavailabilities extends EA_Controller
|
||||||
'id_users_provider',
|
'id_users_provider',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public array $optional_unavailability_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unavailabilities constructor.
|
* Unavailabilities constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +89,8 @@ class Unavailabilities extends EA_Controller
|
||||||
|
|
||||||
$this->unavailabilities_model->only($unavailability, $this->allowed_unavailability_fields);
|
$this->unavailabilities_model->only($unavailability, $this->allowed_unavailability_fields);
|
||||||
|
|
||||||
|
$this->unavailabilities_model->optional($unavailability, $this->optional_unavailability_fields);
|
||||||
|
|
||||||
$unavailability_id = $this->unavailabilities_model->save($unavailability);
|
$unavailability_id = $this->unavailabilities_model->save($unavailability);
|
||||||
|
|
||||||
$unavailability = $this->unavailabilities_model->find($unavailability_id);
|
$unavailability = $this->unavailabilities_model->find($unavailability_id);
|
||||||
|
@ -138,6 +144,8 @@ class Unavailabilities extends EA_Controller
|
||||||
|
|
||||||
$this->unavailabilities_model->only($unavailability, $this->allowed_unavailability_fields);
|
$this->unavailabilities_model->only($unavailability, $this->allowed_unavailability_fields);
|
||||||
|
|
||||||
|
$this->unavailabilities_model->optional($unavailability, $this->optional_unavailability_fields);
|
||||||
|
|
||||||
$unavailability_id = $this->unavailabilities_model->save($unavailability);
|
$unavailability_id = $this->unavailabilities_model->save($unavailability);
|
||||||
|
|
||||||
$unavailability = $this->unavailabilities_model->find($unavailability_id);
|
$unavailability = $this->unavailabilities_model->find($unavailability_id);
|
||||||
|
|
|
@ -22,6 +22,10 @@ class Webhooks extends EA_Controller
|
||||||
{
|
{
|
||||||
public array $allowed_webhook_fields = ['id', 'name', 'url', 'actions', 'secret_token', 'is_ssl_verified', 'notes'];
|
public array $allowed_webhook_fields = ['id', 'name', 'url', 'actions', 'secret_token', 'is_ssl_verified', 'notes'];
|
||||||
|
|
||||||
|
public array $optional_webhook_fields = [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webhooks constructor.
|
* Webhooks constructor.
|
||||||
*/
|
*/
|
||||||
|
@ -136,6 +140,8 @@ class Webhooks extends EA_Controller
|
||||||
|
|
||||||
$this->webhooks_model->only($webhook, $this->allowed_webhook_fields);
|
$this->webhooks_model->only($webhook, $this->allowed_webhook_fields);
|
||||||
|
|
||||||
|
$this->webhooks_model->optional($webhook, $this->optional_webhook_fields);
|
||||||
|
|
||||||
$webhook_id = $this->webhooks_model->save($webhook);
|
$webhook_id = $this->webhooks_model->save($webhook);
|
||||||
|
|
||||||
json_response([
|
json_response([
|
||||||
|
@ -161,6 +167,8 @@ class Webhooks extends EA_Controller
|
||||||
|
|
||||||
$this->webhooks_model->only($webhook, $this->allowed_webhook_fields);
|
$this->webhooks_model->only($webhook, $this->allowed_webhook_fields);
|
||||||
|
|
||||||
|
$this->webhooks_model->optional($webhook, $this->optional_webhook_fields);
|
||||||
|
|
||||||
$webhook_id = $this->webhooks_model->save($webhook);
|
$webhook_id = $this->webhooks_model->save($webhook);
|
||||||
|
|
||||||
json_response([
|
json_response([
|
||||||
|
|
Loading…
Reference in a new issue