$parent
$parent :
User (DB row) base class, as used by our Controllers\Auth trait.
As with the Users base class, this is a minimum, and should be extended.
The user schema must have at least the following fields:
'id' The primary key, generally a SERIAL auto-incrementing integer. 'reset' A string containing a reset code, used to reset the password. 'hash' A string containing the authentication hash. 'token' A string containing a unique identifier used in the hash. 'email' A string containing the primary e-mail address for the user.
Any other fields are up to you, but those are the ones used by the Controllers\Auth trait, and thus required for the methods below.
save()
Save our data back to the database.
If the primary key is set, and has not been modified, this will update the existing record with the new data.
If the primary key has not been set, or has been modified, this will insert a new record into the database, and in the case of auto-generated primary keys, update our primary key field to point to the new record.
changeEmail(String $newemail, Bool $autosave = True) : Bool
Change our e-mail address, ensuring that it is unique.
This is only required in a user model where every user must have a unique e-mail address, such is the case if the e-mail address is used as a login field.
| String | $newemail | The new email address. |
| Bool | $autosave | Save automatically (default True) |
False means e-mail address already in use. True means we updated successfully.