From f540192570f37a6a49b5d435bb6d4d7bd836448d Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sat, 15 Apr 2023 14:34:23 +0200 Subject: [PATCH] Add helper methods to quickly check if a service is assigned to a provider --- application/models/Providers_model.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 8d2c59b4..621fea4c 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -1012,4 +1012,19 @@ class Providers_model extends EA_Model { $provider = $decoded_resource; } + + /** + * Quickly check if a service is assigned to a provider. + * + * @param int $provider_id + * @param int $service_id + * + * @return bool + */ + public function is_service_supported(int $provider_id, int $service_id): bool + { + $provider = $this->find($provider_id); + + return in_array($service_id, $provider['services']); + } }