\Providers_Model

Providers_Model Class

Contains the database operations for the service provider users of Easy!Appointmenst.

Data Structure:

 'fist_name'
 'last_name' (required)
 'email' (required)
 'mobile_number'
 'phone_number' (required)
 'address'
 'city'
 'state'
 'zip_code'
 'notes'
 'id_roles'
 'services' >> array that contains the ids that the provider can provide
 'settings'
     'username'
     'password'
     'notifications'
     'working_plan'
     'google_sync'
     'google_token'
     'google_calendar'
     'sync_past_days'
     'sync_future_days'

Summary

Methods
Properties
Constants
__construct()
add()
exists()
insert()
update()
find_record_id()
validate()
delete()
get_row()
get_value()
get_batch()
get_available_providers()
get_providers_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_settings()
save_services()
No private properties found
N/A

Methods

__construct()

__construct() 

Class Constructor

add()

add(array  $provider) : integer

Add (insert - update) a service provider record.

If the record already exists (id value provided) then it is going to be updated, otherwise inserted into the database.

Parameters

array $provider

Contains the service provider data.

Throws

\Exception

When the record data validation fails.

Returns

integer —

Returns the record id.

exists()

exists(array  $provider) : boolean

Check whether a particular provider record already exists in the database.

Parameters

array $provider

Contains the provider data. The 'email' value is required in order to check for a provider.

Throws

\Exception

When the 'email' value is not provided.

Returns

boolean —

Returns whether the provider record exists or not.

insert()

insert(array  $provider) : integer

Insert a new provider record into the database.

Parameters

array $provider

Contains the provider data (must be already validated).

Throws

\Exception

When the insert operation fails.

Returns

integer —

Returns the new record id.

update()

update(array  $provider) : integer

Update an existing provider record in the database.

Parameters

array $provider

Contains the provider data.

Throws

\Exception

When the update operation fails.

Returns

integer —

Returns the record id.

find_record_id()

find_record_id(array  $provider) : integer

Find the database record id of a provider.

Parameters

array $provider

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

Throws

\Exception

When the provider's email value is not provided.

Returns

integer —

Returns the record id.

validate()

validate(array  $provider) : boolean

Validate provider data before the insert or update operation is executed.

Parameters

array $provider

Contains the provider data.

Returns

boolean —

Returns the validation result.

delete()

delete(  $provider_id) : boolean

Delete an existing provider record from the database.

Parameters

$provider_id

Throws

\Exception

When the provider id value is not numeric.

Returns

boolean —

Returns the delete operation result.

get_row()

get_row(integer  $provider_id) : array

Get a specific provider record from the database.

Parameters

integer $provider_id

The id of the record to be returned.

Throws

\Exception

When the selected record does not exist in database.

Returns

array —

Returns an associative array with the selected record's data. Each key has the same name as the database field names.

get_value()

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

Get a specific field value from the database.

Parameters

string $field_name

The field name of the value to be returned.

\numeric $provider_id

Record id of the value to be returned.

Throws

\Exception

When the $field_name argument is not a valid string.

\Exception

When the $admin_id is not a valid numeric.

\Exception

When the admin 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(mixed  $where_clause = '') : array

Get all, or specific records from provider's table.

Parameters

mixed $where_clause

(OPTIONAL) The WHERE clause of the query to be executed.

NOTICE: DO NOT INCLUDE 'WHERE' KEYWORD.

Returns

array —

Returns the rows from the database.

Examples

= ' . $recordId);
** File not found : $this->Model->get_batch('id **

get_available_providers()

get_available_providers() : array

Get the available system providers.

This method returns the available providers and the services that can provide.

Returns

array —

Returns an array with the providers data.

get_providers_role_id()

get_providers_role_id() : integer

Get the providers role id from the database.

Returns

integer —

Returns the role id for the provider records.

get_setting()

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

Get a providers setting from the database.

Parameters

string $setting_name

The setting name that is going to be returned.

integer $provider_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  $provider_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 $provider_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_settings()

save_settings(array  $settings, \numeric  $provider_id) 

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

Parameters

array $settings

Contains the setting values.

\numeric $provider_id

Record id of the provider.

save_services()

save_services(array  $services, \numeric  $provider_id) 

Save the provider services in the database (use on both insert and update operation).

Parameters

array $services

Contains the service ids that the selected provider can provide.

\numeric $provider_id

The selected provider record id.

Throws

\Exception

When the $services argument type is not array.

\Exception

When the $provider_id argumetn type is not numeric.