Customer
extends CrmClientModel
in package
This class represents the customer info with the account validation status. You can use it as a standalone class but beware of catching exceptions
Be warned that on server side data is normalized
- firstname and lastname are 'capitalized'
- fields are trimmed
- non numeric chars are removed from postcode
Tags
Table of Contents
- $address : string
- $address2 : string
- $birth_date : string
- $city : string
- $country : Country
- $email : string
- $firstname : string
- $hashcode : string
- $last_connection : string
- $lastname : string
- $opt_in : bool
- $password : string
- $phone : string
- $postcode : string
- $status : bool
- $invisibleFields : array<string|int, mixed>
- The crm customer fields the should not be visible
- $modelFields : array<string|int, mixed>
- The crm customer fields
- $validation : array<string|int, mixed>
- Validation rules
- $address : string
- The user address (street number, name, etc)
- $address2 : string
- The user address 2nd part (street number, name, more, etc)
- $birth_date : string
- Birth date
- $city : string
- The user address city
- $country : Country
- The user address postcode
- $email : string
- An RFC Valid Email
- $firstname : string
- First name
- $hashcode : string
- The user hashcode, this is link with the customer and the brand it is related to It is used to identify the customer itself.
- $last_connection : string
- The last time the account was connected
- $lastname : string
- Last name
- $opt_in : bool
- The user optin choice
- $password : string
- The user password This is set only when creating a user Otherwise it has to be set to null
- $phone : string
- The user phone
- $postcode : string
- The user address postcode
- $status : bool
- Is the account activated ?
- __construct() : mixed
- Customer
- __get() : mixed|null
- Generic accessor
- __set() : void
- Set prop on the model.
- activate() : bool
- Active the customer on CRM.
- delete() : bool
- Removes the customer from CRM.
- fill() : void
- Fill values into model using validation rules.
- find() : self|null
- Find a customer using its hashcode in the crm
- findWithEmail() : self|null
- Find a customer using its email in the crm This is an alias of Customer::find()
- jsonSerialize() : array<string|int, mixed>
- Serialize this object to an array
- login() : bool
- Test customer credentials
- save() : bool
- Save the customer on CRM.
- toggleOptin() : bool
- Toggle the account optin value in the crm
- validateAllValues() : array<string|int, mixed>
- Validate all model properties
- store() : bool
- Calls api store customer method
- update() : bool
- Calls api update customer method
Properties
$address
public
string
$address
The account address (street number, name, build, flat number)
$address2
public
string
$address2
The account phone (address complement)
$birth_date
public
string
$birth_date
The account birth date 'yyyy-mm-dd'
$city
public
string
$city
The account city name
$country
public
Country
$country
The account country residence
public
string
$email
Must be a rfc valid email on a valid domain name
$firstname
public
string
$firstname
The account first name
$hashcode
public
string
$hashcode
The crm hashcode this is a readonly field
$last_connection
public
string
$last_connection
the last time user was connected 'yyyy-mm-dd HH:ii:ss'
$lastname
public
string
$lastname
The account last name
$opt_in
public
bool
$opt_in
true if the account is opt in
$password
public
string
$password
Required only on create, must have upper and lowers chars, at least 1 number, at leat 1 upper char, at least 1 lower char and at leat 1 special char
$phone
public
string
$phone
The account phone
$postcode
public
string
$postcode
The account city postcode
$status
public
bool
$status
true if the account is activated
$invisibleFields
The crm customer fields the should not be visible
protected
array<string|int, mixed>
$invisibleFields
= ['password']
$modelFields
The crm customer fields
protected
array<string|int, mixed>
$modelFields
= ['hashcode', 'email', 'firstname', 'password', 'lastname', 'birth_date', 'phone', 'address', 'address2', 'city', 'postcode', 'country', 'opt_in', 'status', 'last_connection']
$validation
Validation rules
protected
static array<string|int, mixed>
$validation
= ['hashcode' => 'required|uuid', 'email' => 'required|email', 'firstname' => 'required|string|min:1|max:255', 'lastname' => 'required|string|min:1|max:255', 'password' => 'required|min:8|max:255|mixedCase|containDigit|containSymbol', 'birth_date' => 'required|date_format:Y-m-d', 'phone' => 'sometimes|nullable|string|max:255', 'address' => 'sometimes|string|max:255', 'address2' => 'sometimes|string|max:255', 'city' => 'sometimes|string|min:2|max:255', 'postcode' => 'sometimes|string|max:255', 'country' => ['sometimes'], 'opt_in' => 'required|bool', 'status' => 'required|bool', 'last_connection' => 'sometimes|date']
$address
The user address (street number, name, etc)
private
string
$address
= null
Validate: sometimes,string
Min length NA Max length 255 Field Type varchar
$address2
The user address 2nd part (street number, name, more, etc)
private
string
$address2
= null
Validate: sometimes,string
Min length NA Max length 255 Field Type varchar
$birth_date
Birth date
private
string
$birth_date
= null
Validate: date_format:Y-m-d
Required Field Type Date
$city
The user address city
private
string
$city
= null
Validate: sometimes,string
Min length NA Max length 255 Field Type varchar
$country
The user address postcode
private
Country
$country
= null
Validate: sometimes, in Country::toValues()
Required Field Type tinyInt
An RFC Valid Email
private
string
$email
= null
Validate: rfc,dns,spoof,filter
Required Min length N/A Max length 255 Field Type varchar
$firstname
First name
private
string
$firstname
= null
Required Min length 2 Max length 255 Field Type varchar
$hashcode
The user hashcode, this is link with the customer and the brand it is related to It is used to identify the customer itself.
private
string
$hashcode
Validate: UUID, in customer_infos
Required Min length 36 Max length 36 Field Type varchar
$last_connection
The last time the account was connected
private
string
$last_connection
= null
This field is read only
$lastname
Last name
private
string
$lastname
= null
Required Min length 2 Max length 255 Field Type varchar
$opt_in
The user optin choice
private
bool
$opt_in
= false
Validate: boolean
Required Field Type TinyInt
$password
The user password This is set only when creating a user Otherwise it has to be set to null
private
string
$password
= null
Validate: case_diff,numbers,letters,symbols,min:8
Min length 8 Max length 255 Field Type varchar
$phone
The user phone
private
string
$phone
= null
Validate: sometimes,string
Required Min length NA Max length 255 Field Type varchar
$postcode
The user address postcode
private
string
$postcode
= null
Validate: string
Required Min length NA Max length 255 Field Type varchar
$status
Is the account activated ?
private
bool
$status
= false
This field is read only
Methods
__construct()
Customer
public
__construct([array<string|int, mixed> $properties = [] ]) : mixed
Parameters
- $properties : array<string|int, mixed> = []
Tags
Return values
mixed —__get()
Generic accessor
public
__get(string $field) : mixed|null
Parameters
- $field : string
Return values
mixed|null —Returns null if the property was not found any way.
__set()
Set prop on the model.
public
__set(string $field, mixed $value) : void
Parameters
- $field : string
- $value : mixed
Tags
Return values
void —activate()
Active the customer on CRM.
public
activate() : bool
Tags
Return values
bool —true if succeeded
delete()
Removes the customer from CRM.
public
delete() : bool
Tags
Return values
bool —true if succeeded
fill()
Fill values into model using validation rules.
public
fill(array<string|int, mixed> $properties) : void
Parameters
- $properties : array<string|int, mixed>
Tags
Return values
void —find()
Find a customer using its hashcode in the crm
public
static find(string $hashcode) : self|null
Parameters
- $hashcode : string
Tags
Return values
self|null —Return null if the customer was not found
findWithEmail()
Find a customer using its email in the crm This is an alias of Customer::find()
public
static findWithEmail(string $email) : self|null
Parameters
- $email : string
Tags
Return values
self|null —jsonSerialize()
Serialize this object to an array
public
jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed> —login()
Test customer credentials
public
static login(string $email, string $password) : bool
Parameters
- $email : string
- $password : string
Tags
Return values
bool —save()
Save the customer on CRM.
public
save() : bool
Tags
Return values
bool —True if save was successfull.
toggleOptin()
Toggle the account optin value in the crm
public
toggleOptin() : bool
Tags
Return values
bool —true if succeeded
validateAllValues()
Validate all model properties
protected
validateAllValues([array<string|int, mixed> $ignore = [] ]) : array<string|int, mixed>
Parameters
- $ignore : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed> —the validated values
store()
Calls api store customer method
private
store() : bool
Tags
Return values
bool —True if save was successfull.
update()
Calls api update customer method
private
update() : bool
Tags
Return values
bool —True if save was successfull.