\Secretaries_Model

Secretaries Model

Handles the db actions that have to do with secretaries.

Data Structure

 'first_name'
 'last_name'
 'email'
 'mobile_number'
 'phone_number'
 'address'
 'city'
 'state'
 'zip_code'
 'notes'
 'id_roles'
 'providers' >> array with provider ids that the secretary handles
 'settings' >> array with the secretary settings

Summary

Methods
Properties
Constants
__construct()
add()
exists()
insert()
update()
find_record_id()
validate()
delete()
get_row()
get_value()
get_batch()
get_secretary_role_id()
get_setting()
set_setting()
validate_username()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
save_providers()
save_settings()
No private properties found
N/A

Methods

__construct()

__construct() 

Class Constructor

add()

add(array  $secretary) : integer

Add (insert or update) a secretary user record into database.

Parameters

array $secretary

Contains the secretary user data.

Throws

\Exception

When the secretary data are invalid (see validate() method).

Returns

integer —

Returns the record id.

exists()

exists(array  $secretary) : boolean

Check whether a particular secretary record exists in the database.

Parameters

array $secretary

Contains the secretary data. The 'email' value is required to be present at the moment.

Throws

\Exception

When the 'email' value is not present on the $secretary argument.

Returns

boolean —

Returns whether the record exists or not.

insert()

insert(array  $secretary) : integer

Insert a new sercretary record into the database.

Parameters

array $secretary

Contains the secretary data.

Throws

\Exception

When the insert operation fails.

Returns

integer —

Returns the new record id.

update()

update(array  $secretary) : integer

Update an existing secretary record in the database.

Parameters

array $secretary

Contains the secretary record data.

Throws

\Exception

When the update operation fails.

Returns

integer —

Retuns the record id.

find_record_id()

find_record_id(array  $secretary) : integer

Find the database record id of a secretary.

Parameters

array $secretary

Contains the secretary data. The 'email' value is required in order to find the record id.

Throws

\Exception

When the 'email' value is not present on the $secretary array.

Returns

integer —

Returns the record id

validate()

validate(array  $secretary) : boolean

Validate secretary user data before add() operation is executed.

Parameters

array $secretary

Contains the secretary user data.

Returns

boolean —

Returns the validation result.

delete()

delete(\numeric  $secretary_id) : boolean

Delete an existing secretary record from the database.

Parameters

\numeric $secretary_id

The secretary record id to be deleted.

Throws

\Exception

When the $secretary_id is not a valid numeric value.

Returns

boolean —

Returns the delete operation result.

get_row()

get_row(\numeric  $secretary_id) : array

Get a specific secretary record from the database.

Parameters

\numeric $secretary_id

The id of the record to be returned.

Throws

\Exception

When the $secretary_id is not a valid numeric value.

\Exception

When given record id does not exist in the database.

Returns

array —

Returns an array with the secretary user data.

get_value()

get_value(string  $field_name, \numeric  $secretary_id) : string

Get a specific field value from the database.

Parameters

string $field_name

The field name of the value to be returned.

\numeric $secretary_id

Record id of the value to be returned.

Throws

\Exception

When the $field_name argument is not a valid string.

\Exception

When the $secretary_id is not a valid numeric.

\Exception

When the secretary record does not exist in the database.

\Exception

When the selected field value is not present on database.

Returns

string —

Returns the selected record value from the database.

get_batch()

get_batch(string|array  $where_clause = '') : array

Get all, or specific secretary records from database.

Parameters

string|array $where_clause

(OPTIONAL) The WHERE clause of the query to be executed. Use this to get specific secretary records.

Returns

array —

Returns an array with secretary records.

get_secretary_role_id()

get_secretary_role_id() : integer

Get the secretary users role id.

Returns

integer —

Returns the role record id.

get_setting()

get_setting(string  $setting_name, integer  $secretary_id) : string

Get a providers setting from the database.

Parameters

string $setting_name

The setting name that is going to be returned.

integer $secretary_id

The selected provider id.

Returns

string —

Returs the value of the selected user setting.

set_setting()

set_setting(string  $setting_name, string  $value, \numeric  $secretary_id) 

Set a provider's setting value in the database.

The provider and settings record must already exist.

Parameters

string $setting_name

The setting's name.

string $value

The setting's value.

\numeric $secretary_id

The selected provider id.

validate_username()

validate_username(string  $username, \numeric  $user_id) : boolean

Validate Records Username

Parameters

string $username

The provider records username.

\numeric $user_id

The user record id.

Returns

boolean —

Returns the validation result.

save_providers()

save_providers(array  $providers, \numeric  $secretary_id) 

Save a secretary hasndling users.

Parameters

array $providers

Contains the provider ids that are handled by the secretary.

\numeric $secretary_id

The selected secretary record.

save_settings()

save_settings(array  $settings, \numeric  $secretary_id) 

Save the secretary settings (used from insert or update operation).

Parameters

array $settings

Contains the setting values.

\numeric $secretary_id

Record id of the secretary.