diff --git a/application/controllers/Account.php b/application/controllers/Account.php index 806e3d69..25848ce5 100644 --- a/application/controllers/Account.php +++ b/application/controllers/Account.php @@ -36,8 +36,17 @@ class Account extends EA_Controller 'language', 'settings', ]; + + public array $optional_user_fields = [ + // + ]; + public array $allowed_user_setting_fields = ['username', 'password', 'notifications', 'calendar_view']; + public array $optional_user_setting_fields = [ + // + ]; + /** * Account constructor. */ @@ -110,8 +119,12 @@ class Account extends EA_Controller $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->optional($account['settings'], $this->optional_user_setting_fields); + if (empty($account['password'])) { unset($account['password']); } diff --git a/application/controllers/Admins.php b/application/controllers/Admins.php index a8619a3d..a03bac82 100644 --- a/application/controllers/Admins.php +++ b/application/controllers/Admins.php @@ -38,8 +38,16 @@ class Admins extends EA_Controller 'settings', ]; + public array $optional_admin_fields = [ + // + ]; + public array $allowed_admin_setting_fields = ['username', 'password', 'notifications', 'calendar_view']; + public array $optional_admin_settings_fields = [ + // + ]; + /** * Admins constructor. */ @@ -139,8 +147,12 @@ class Admins extends EA_Controller $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->optional($admin['settings'], $this->optional_admin_setting_fields); + $admin_id = $this->admins_model->save($admin); $admin = $this->admins_model->find($admin_id); diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index 6d6640e3..0a31def1 100644 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -37,6 +37,10 @@ class Appointments extends EA_Controller 'id_services', ]; + public array $optional_appointment_fields = [ + // + ]; + /** * Appointments constructor. */ @@ -104,6 +108,8 @@ class Appointments extends EA_Controller $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 = $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->optional($appointment, $this->optional_appointment_fields); + $appointment_id = $this->appointments_model->save($appointment); json_response([ diff --git a/application/controllers/Blocked_periods.php b/application/controllers/Blocked_periods.php index 9c0ca605..780034e4 100644 --- a/application/controllers/Blocked_periods.php +++ b/application/controllers/Blocked_periods.php @@ -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 $optional_blocked_period_fields = [ + // + ]; + /** * 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->optional($blocked_period, $this->optional_blocked_period_fields); + $blocked_period_id = $this->blocked_periods_model->save($blocked_period); $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->optional($blocked_period, $this->optional_blocked_period_fields); + $blocked_period_id = $this->blocked_periods_model->save($blocked_period); $blocked_period = $this->blocked_periods_model->find($blocked_period_id); diff --git a/application/controllers/Booking_settings.php b/application/controllers/Booking_settings.php index df5df30e..ed760023 100644 --- a/application/controllers/Booking_settings.php +++ b/application/controllers/Booking_settings.php @@ -22,6 +22,10 @@ class Booking_settings extends EA_Controller { public array $allowed_setting_fields = ['id', 'name', 'value']; + public array $optional_setting_fields = [ + // + ]; + /** * 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->optional($setting, $this->optional_setting_fields); + $this->settings_model->save($setting); } diff --git a/application/controllers/Business_settings.php b/application/controllers/Business_settings.php index cef2806b..f9b30ca6 100644 --- a/application/controllers/Business_settings.php +++ b/application/controllers/Business_settings.php @@ -20,6 +20,12 @@ */ class Business_settings extends EA_Controller { + public array $allowed_setting_fields = ['id', 'name', 'value']; + + public array $optional_setting_fields = [ + // + ]; + /** * Business_logic constructor. */ @@ -102,7 +108,9 @@ class Business_settings extends EA_Controller $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); } diff --git a/application/controllers/Calendar.php b/application/controllers/Calendar.php index 250957bc..02dc9dde 100644 --- a/application/controllers/Calendar.php +++ b/application/controllers/Calendar.php @@ -39,6 +39,11 @@ class Calendar extends EA_Controller 'custom_field_4', 'custom_field_5', ]; + + public array $optional_customer_fields = [ + // + ]; + public array $allowed_appointment_fields = [ 'id', 'start_datetime', @@ -53,6 +58,10 @@ class Calendar extends EA_Controller 'id_services', ]; + public array $optional_appointment_fields = [ + // + ]; + /** * Calendar constructor. */ @@ -237,6 +246,8 @@ class Calendar extends EA_Controller $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); } @@ -266,6 +277,8 @@ class Calendar extends EA_Controller $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); } diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php index 9809957a..3e8419f7 100644 --- a/application/controllers/Customers.php +++ b/application/controllers/Customers.php @@ -41,6 +41,10 @@ class Customers extends EA_Controller 'ldap_dn', ]; + public array $optional_customer_fields = [ + // + ]; + /** * Customers constructor. */ @@ -220,6 +224,8 @@ class Customers extends EA_Controller $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 = $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->optional($customer, $this->optional_customer_fields); + $customer_id = $this->customers_model->save($customer); $customer = $this->customers_model->find($customer_id); diff --git a/application/controllers/Providers.php b/application/controllers/Providers.php index b29c0257..dda1f3db 100644 --- a/application/controllers/Providers.php +++ b/application/controllers/Providers.php @@ -40,6 +40,11 @@ class Providers extends EA_Controller 'settings', 'services', ]; + + public array $optional_provider_fields = [ + 'services' => [], + ]; + public array $allowed_provider_setting_fields = [ 'username', 'password', @@ -48,16 +53,14 @@ class Providers extends EA_Controller 'notifications', 'calendar_view', ]; - public array $allowed_service_fields = ['id', 'name']; - public array $optional_provider_fields = [ - 'services' => [], - ]; public array $optional_provider_setting_fields = [ 'working_plan' => null, 'working_plan_exceptions' => '{}', ]; + public array $allowed_service_fields = ['id', 'name']; + /** * Providers constructor. */ diff --git a/application/controllers/Service_categories.php b/application/controllers/Service_categories.php index e49980de..8f77f7d2 100644 --- a/application/controllers/Service_categories.php +++ b/application/controllers/Service_categories.php @@ -22,6 +22,8 @@ class Service_categories extends EA_Controller { public array $allowed_service_category_fields = ['id', 'name', 'description']; + public array $optional_service_category_fields = []; + /** * 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->optional($service_category, $this->optional_service_category_fields); + $service_category_id = $this->service_categories_model->save($service_category); $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->optional($service_category, $this->optional_service_category_fields); + $service_category_id = $this->service_categories_model->save($service_category); $service_category = $this->service_categories_model->find($service_category_id); diff --git a/application/controllers/Unavailabilities.php b/application/controllers/Unavailabilities.php index 326c7eab..4ea8d015 100644 --- a/application/controllers/Unavailabilities.php +++ b/application/controllers/Unavailabilities.php @@ -30,6 +30,10 @@ class Unavailabilities extends EA_Controller 'id_users_provider', ]; + public array $optional_unavailability_fields = [ + // + ]; + /** * Unavailabilities constructor. */ @@ -85,6 +89,8 @@ class Unavailabilities extends EA_Controller $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 = $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->optional($unavailability, $this->optional_unavailability_fields); + $unavailability_id = $this->unavailabilities_model->save($unavailability); $unavailability = $this->unavailabilities_model->find($unavailability_id); diff --git a/application/controllers/Webhooks.php b/application/controllers/Webhooks.php index 36383c46..47f6bf80 100644 --- a/application/controllers/Webhooks.php +++ b/application/controllers/Webhooks.php @@ -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 $optional_webhook_fields = [ + // + ]; + /** * Webhooks constructor. */ @@ -136,6 +140,8 @@ class Webhooks extends EA_Controller $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); json_response([ @@ -161,6 +167,8 @@ class Webhooks extends EA_Controller $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); json_response([