From 879b58ad6a3509d885dab4a644f0f61d5a94375c Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Fri, 29 Oct 2021 12:39:14 +0200 Subject: [PATCH] Type casting for the Secretaries_model.php --- application/models/Secretaries_model.php | 32 +++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/application/models/Secretaries_model.php b/application/models/Secretaries_model.php index 67379bee..97513882 100644 --- a/application/models/Secretaries_model.php +++ b/application/models/Secretaries_model.php @@ -19,6 +19,14 @@ * @package Models */ class Secretaries_model extends EA_Model { + /** + * @var array + */ + protected $casts = [ + 'id' => 'integer', + 'id_roles' => 'integer', + ]; + /** * Save (insert or update) a secretary. * @@ -516,7 +524,7 @@ class Secretaries_model extends EA_Model { { $role_id = $this->get_secretary_role_id(); - return $this + $secretaries = $this ->db ->select() ->from('users') @@ -536,6 +544,28 @@ class Secretaries_model extends EA_Model { ->order_by($order_by) ->get() ->result_array(); + + foreach ($secretaries as &$secretary) + { + $secretary['settings'] = $this->db->get_where('user_settings', ['id_users' => $secretary['id']])->row_array(); + + unset( + $secretary['settings']['id_users'], + $secretary['settings']['password'], + $secretary['settings']['salt'] + ); + + $secretary_provider_connections = $this->db->get_where('secretaries_providers', ['id_users_secretary' => $secretary['id']])->result_array(); + + $secretary['providers'] = []; + + foreach ($secretary_provider_connections as $secretary_provider_connection) + { + $secretary['providers'][] = (int)$secretary_provider_connection['id_users_provider']; + } + } + + return $secretaries; } /**