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' 'sync_past_days'
'sync_future_days'
Methods summary
public
|
|
public
integer
|
#
add( array $provider )
Add (insert - update) a service provider record.
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
- $provider
array $provider Contains the service provider data.
Returns
integer Returns the record id.
Throws
Exception
When the record data validation fails.
|
public
boolean
|
#
exists( array $provider )
Check whether a particular provider record already exists in the
database.
Check whether a particular provider record already exists in the
database.
Parameters
- $provider
array $provider Contains the provider data. The 'email' value is required in order to
check for a provider.
Returns
boolean Returns whether the provider record exists or not.
Throws
Exception
When the 'email' value is not provided.
|
public
integer
|
#
insert( array $provider )
Insert a new provider record into the database.
Insert a new provider record into the database.
Parameters
- $provider
array $provider Contains the provider data (must be already validated).
Returns
integer Returns the new record id.
Throws
|
public
integer
|
#
update( array $provider )
Update an existing provider record in the database.
Update an existing provider record in the database.
Parameters
- $provider
array $provider Contains the provider data.
Returns
integer Returns the record id.
Throws
|
public
integer
|
#
find_record_id( array $provider )
Find the database record id of a provider.
Find the database record id of a provider.
Parameters
- $provider
array $provider Contains the provider data. The 'email' value is required in order to
find the record id.
Returns
integer Returns the record id.
Throws
Exception
When the provider's email value is not provided.
|
public
boolean
|
#
validate( array $provider )
Validate provider data before the insert or update operation is executed.
Validate provider data before the insert or update operation is executed.
Parameters
- $provider
array $provider Contains the provider data.
Returns
boolean Returns the validation result.
|
public
boolean
|
#
delete( numeric $provider_id )
Delete an existing provider record from the database.
Delete an existing provider record from the database.
Parameters
- $provider_id
numeric $customer_id The record id to be deleted.
Returns
boolean Returns the delete operation result.
Throws
Exception
When the provider id value is not numeric.
|
public
array
|
#
get_row( integer $provider_id )
Get a specific provider record from the database.
Get a specific provider record from the database.
Parameters
- $provider_id
integer $provider_id The id of the record to be returned.
Returns
array Returns an associative array with the selected record's data. Each key has the
same name as the database field names.
Throws
Exception
When the selected record does not exist in database.
|
public
string
|
#
get_value( string $field_name, numeric $provider_id )
Get a specific field value from the database.
Get a specific field value from the database.
Parameters
- $field_name
string $field_name The field name of the value to be returned.
- $provider_id
numeric $provider_id Record id of the value to be returned.
Returns
string Returns the selected record value from the database.
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.
|
public
array
|
#
get_batch( mixed $where_clause = '' )
Get all, or specific records from provider's table.
Get all, or specific records from provider's table.
Parameters
- $where_clause
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.
Example
$this->Model->get_batch('id = ' . $recordId);
|
public
integer
|
#
get_providers_role_id( )
Get the providers role id from the database.
Get the providers role id from the database.
Returns
integer Returns the role id for the provider records.
|
public
string
|
#
get_setting( string $setting_name, integer $provider_id )
Get a providers setting from the database.
Get a providers setting from the database.
Parameters
- $setting_name
string $setting_name The setting name that is going to be returned.
- $provider_id
integer $provider_id The selected provider id.
Returns
string Returs the value of the selected user setting.
|
public
|
#
set_setting( string $setting_name, string $value, numeric $provider_id )
Set a provider's setting value in the database.
Set a provider's setting value in the database.
The provider and settings record must already exist.
Parameters
- $setting_name
string $setting_name The setting's name.
- $value
string $value The setting's value.
- $provider_id
numeric $provider_id The selected provider id.
|