Users
extends Model
in package
implements
UserProviderInterface
Uses
Uuid, Find, Status, DateCreated, SoftDelete, Auth, Password
Users database model
Table of Contents
Interfaces
- UserProviderInterface
- User auth interface
Properties
- $ACTIVE : mixed
- Active
- $CANCELLED : mixed
- Cancelled
- $COMPLETED : mixed
- Completed
- $DISABLED : mixed
- Disabled
- $PENDING : mixed
- Pending activation
- $PUBLISHED : mixed
- Published
- $SUSPENDED : mixed
- Suspended
- $timestamps : bool
- Disable timestamps
- $DEFAULT_SOFT_DELETE_COLUMN : string
- Default soft delete column mame
- $DEFAULT_STATUS_COLUMN : string
- Default status column name
- $DEFAULT_UUID_COLUMN : string
- Default uuid column name
- $fillable : array<string|int, mixed>
- Fillable attributes
- $hidden : array<string|int, mixed>
- Hidden attributes
- $statusText : array<string|int, mixed>
- Status text
- $table : string
- Db table name
Methods
- ACTIVE() : int
- Return active value
- bootDateCreated() : void
- Set model events
- bootUuid() : void
- Init model events.
- CANCELLED() : int
- Cancelled
- changePassword() : bool
- Change password
- clearDeleted() : bool
- Permanently delete all soft deleted models
- COMPLETED() : int
- Return completed value
- createUser() : Model|false
- Create user
- deleteUser() : bool
- Hard delete user
- details() : Relation|null
- User details relation
- DISABLED() : int
- Return disabled value
- encryptPassword() : string
- Encrypt password
- findByColumn() : Model|null
- Find model by column name
- findById() : Model|null
- Find model by id or uuid
- findByIdQuery() : Builder
- Return query builder
- findItems() : QueryBuilder|false
- Find collection of models by id or uuid
- findMultiple() : Builder
- Find multiole query
- findQuery() : Builder
- Return query builder
- findUser() : Model|null
- Find user by username or email
- getActive() : Builder
- Return active model query builder
- getAuthId() : mixed
- Return auth id
- getAuthIdName() : string
- Return Auth id name
- getControlPanelUser() : Model|null
- Get user with control panel permission
- getDateCreatedAttributeName() : string
- Get date created attribute
- getDeletedCount() : int
- Get delete models count.
- getDisabled() : Builder
- Return disabled model query builder
- getEncryptPasswordAlgo() : mixed
- Return encrypt algo
- getIdAttributeName() : string
- Return id column name dependiv of id value type for string return uuid
- getLastId() : int|null
- Get last id
- getLastRow() : Model|null
- Get last row
- getNotDeletedQuery() : QueryBuilder
- Get not deleted query
- getPassword() : string
- Get password
- getPasswordAttributeName() : string
- Return password attribute name
- getUser() : Model|null
- Find user by user name or email
- getUserByCredentials() : array<string|int, mixed>|null
- Get user by credentails
- getUserById() : array<string|int, mixed>|null
- Return user details by auth id
- getUserNameOrEmailAttribute() : string
- Get user_name_or_email attribute
- groups() : Relation
- User groups relation
- hasAttribute() : bool
- Return true if atr exist
- hasControlPanelUser() : bool
- Return true if admin user exist
- hasUserEmail() : bool
- Return true if email exist
- hasUserName() : bool
- Return true if username exist
- isControlPanelUser() : bool
- Return true if user have control panel permission
- isDeleted() : bool
- Return true if model is deleted
- PENDING() : int
- Pending activation
- resolveStatusText() : int|false
- Resolve status id
- resolveStatusValue() : int
- Get status value
- restore() : bool
- Restore soft deleted models
- restoreAll() : bool
- Restore all soft deleted rows
- scopeActiveQuery() : Builder
- Active status scope
- scopeGetDeleted() : Builder
- Get deleted scope
- scopeGetNotDeleted() : Builder
- Get not deleted scope
- scopeSearchIgnoreCase() : Builder
- Case insensitive search
- scopeStatusQuery() : Builder
- Status scope
- setStatus() : bool
- Set model status
- softDelete() : bool
- Soft delete model
- softDeletedQuery() : QueryBuilder
- Get soft deleted query
- SUSPENDED() : int
- Suspended
- updateLoginDate() : bool
- Set login date to current time
- verifyEmail() : array<string|int, mixed>|false
- Get user by email
- verifyPassword() : bool
- Return true if password is correct.
- verifyUserName() : bool
- Verify username
- whereIgnoreCase() : Builder
- Where case insensitive
Properties
$ACTIVE
Active
public
static mixed
$ACTIVE
= 1
$CANCELLED
Cancelled
public
static mixed
$CANCELLED
= 6
$COMPLETED
Completed
public
static mixed
$COMPLETED
= 2
$DISABLED
Disabled
public
static mixed
$DISABLED
= 0
$PENDING
Pending activation
public
static mixed
$PENDING
= 4
$PUBLISHED
Published
public
static mixed
$PUBLISHED
= 3
$SUSPENDED
Suspended
public
static mixed
$SUSPENDED
= 5
$timestamps
Disable timestamps
public
bool
$timestamps
= false
$DEFAULT_SOFT_DELETE_COLUMN
Default soft delete column mame
protected
static string
$DEFAULT_SOFT_DELETE_COLUMN
= 'date_deleted'
$DEFAULT_STATUS_COLUMN
Default status column name
protected
static string
$DEFAULT_STATUS_COLUMN
= 'status'
$DEFAULT_UUID_COLUMN
Default uuid column name
protected
static string
$DEFAULT_UUID_COLUMN
= 'uuid'
$fillable
Fillable attributes
protected
array<string|int, mixed>
$fillable
= ['uuid', 'user_name', 'email', 'status', 'password', 'date_login', 'date_created', 'date_deleted']
$hidden
Hidden attributes
protected
array<string|int, mixed>
$hidden
= ['password']
$statusText
Status text
protected
array<string|int, mixed>
$statusText
= ['disabled', 'active', 'completed', 'published', 'pending', 'suspended', 'cancelled']
$table
Db table name
protected
string
$table
= 'users'
Methods
ACTIVE()
Return active value
public
ACTIVE() : int
Return values
intbootDateCreated()
Set model events
public
static bootDateCreated() : void
bootUuid()
Init model events.
public
static bootUuid() : void
CANCELLED()
Cancelled
public
CANCELLED() : int
Return values
intchangePassword()
Change password
public
changePassword(string|int $id, string $password) : bool
Parameters
- $id : string|int
- $password : string
Return values
boolclearDeleted()
Permanently delete all soft deleted models
public
clearDeleted() : bool
Return values
boolCOMPLETED()
Return completed value
public
COMPLETED() : int
Return values
intcreateUser()
Create user
public
createUser(string $userName, string $password[, string|null $email = null ]) : Model|false
Parameters
- $userName : string
- $password : string
- $email : string|null = null
Return values
Model|falsedeleteUser()
Hard delete user
public
deleteUser() : bool
Return values
booldetails()
User details relation
public
details() : Relation|null
Return values
Relation|nullDISABLED()
Return disabled value
public
DISABLED() : int
Return values
intencryptPassword()
Encrypt password
public
encryptPassword(string $password[, int $algo = null ]) : string
Parameters
- $password : string
- $algo : int = null
Return values
stringfindByColumn()
Find model by column name
public
findByColumn(mixed $value[, string|null|array<string|int, mixed> $column = null ]) : Model|null
Parameters
- $value : mixed
- $column : string|null|array<string|int, mixed> = null
Return values
Model|nullfindById()
Find model by id or uuid
public
findById(int|string $id) : Model|null
Parameters
- $id : int|string
Return values
Model|nullfindByIdQuery()
Return query builder
public
findByIdQuery(int|string $id) : Builder
Parameters
- $id : int|string
Return values
BuilderfindItems()
Find collection of models by id or uuid
public
findItems(array<string|int, mixed>|null $items) : QueryBuilder|false
Parameters
- $items : array<string|int, mixed>|null
Return values
QueryBuilder|falsefindMultiple()
Find multiole query
public
findMultiple(array<string|int, mixed> $idList) : Builder
Parameters
- $idList : array<string|int, mixed>
Return values
BuilderfindQuery()
Return query builder
public
findQuery(mixed $value[, string|null|array<string|int, mixed> $column = null ]) : Builder
Parameters
- $value : mixed
- $column : string|null|array<string|int, mixed> = null
Return values
BuilderfindUser()
Find user by username or email
public
findUser(string $userName) : Model|null
Parameters
- $userName : string
Return values
Model|nullgetActive()
Return active model query builder
public
getActive() : Builder
Return values
BuildergetAuthId()
Return auth id
public
getAuthId() : mixed
getAuthIdName()
Return Auth id name
public
getAuthIdName() : string
Return values
stringgetControlPanelUser()
Get user with control panel permission
public
getControlPanelUser() : Model|null
Return values
Model|nullgetDateCreatedAttributeName()
Get date created attribute
public
getDateCreatedAttributeName() : string
Return values
stringgetDeletedCount()
Get delete models count.
public
getDeletedCount() : int
Return values
intgetDisabled()
Return disabled model query builder
public
getDisabled() : Builder
Return values
BuildergetEncryptPasswordAlgo()
Return encrypt algo
public
getEncryptPasswordAlgo() : mixed
getIdAttributeName()
Return id column name dependiv of id value type for string return uuid
public
getIdAttributeName(int|string $id) : string
Parameters
- $id : int|string
Return values
stringgetLastId()
Get last id
public
getLastId() : int|null
Return values
int|nullgetLastRow()
Get last row
public
getLastRow([string $field = 'id' ]) : Model|null
Parameters
- $field : string = 'id'
Return values
Model|nullgetNotDeletedQuery()
Get not deleted query
public
getNotDeletedQuery() : QueryBuilder
Return values
QueryBuildergetPassword()
Get password
public
getPassword() : string
Return values
stringgetPasswordAttributeName()
Return password attribute name
public
getPasswordAttributeName() : string
Return values
stringgetUser()
Find user by user name or email
public
getUser(string|null $userName[, string|null $email = null ]) : Model|null
Parameters
- $userName : string|null
- $email : string|null = null
Return values
Model|nullgetUserByCredentials()
Get user by credentails
public
getUserByCredentials(array<string|int, mixed> $credentials) : array<string|int, mixed>|null
Parameters
- $credentials : array<string|int, mixed>
Return values
array<string|int, mixed>|nullgetUserById()
Return user details by auth id
public
getUserById(string|int $id) : array<string|int, mixed>|null
Parameters
- $id : string|int
Return values
array<string|int, mixed>|nullgetUserNameOrEmailAttribute()
Get user_name_or_email attribute
public
getUserNameOrEmailAttribute() : string
Return values
stringgroups()
User groups relation
public
groups() : Relation
Return values
RelationhasAttribute()
Return true if atr exist
public
hasAttribute(string $attr) : bool
Parameters
- $attr : string
Return values
boolhasControlPanelUser()
Return true if admin user exist
public
hasControlPanelUser() : bool
Return values
boolhasUserEmail()
Return true if email exist
public
hasUserEmail(string $email) : bool
Parameters
- $email : string
Return values
boolhasUserName()
Return true if username exist
public
hasUserName(string $userName) : bool
Parameters
- $userName : string
Return values
boolisControlPanelUser()
Return true if user have control panel permission
public
isControlPanelUser([int|null $id = null ]) : bool
Parameters
- $id : int|null = null
Return values
boolisDeleted()
Return true if model is deleted
public
isDeleted() : bool
Return values
boolPENDING()
Pending activation
public
PENDING() : int
Return values
intresolveStatusText()
Resolve status id
public
resolveStatusText(string|int $status) : int|false
Parameters
- $status : string|int
Return values
int|falseresolveStatusValue()
Get status value
public
resolveStatusValue([int|null|string $status = null ]) : int
Parameters
- $status : int|null|string = null
Return values
intrestore()
Restore soft deleted models
public
restore([mixed $id = null ]) : bool
Parameters
- $id : mixed = null
Return values
boolrestoreAll()
Restore all soft deleted rows
public
restoreAll() : bool
Return values
boolscopeActiveQuery()
Active status scope
public
scopeActiveQuery(Builder $query) : Builder
Parameters
- $query : Builder
Return values
BuilderscopeGetDeleted()
Get deleted scope
public
scopeGetDeleted(Builder $query) : Builder
Parameters
- $query : Builder
Return values
BuilderscopeGetNotDeleted()
Get not deleted scope
public
scopeGetNotDeleted(Builder $query) : Builder
Parameters
- $query : Builder
Return values
BuilderscopeSearchIgnoreCase()
Case insensitive search
public
scopeSearchIgnoreCase(Builder $query, string $column, string|null $value) : Builder
Parameters
- $query : Builder
- $column : string
- $value : string|null
Return values
BuilderscopeStatusQuery()
Status scope
public
scopeStatusQuery(Builder $query, mixed $items) : Builder
Parameters
- $query : Builder
- $items : mixed
Return values
BuildersetStatus()
Set model status
public
setStatus([int|string|null $status = null ]) : bool
Parameters
- $status : int|string|null = null
Return values
boolsoftDelete()
Soft delete model
public
softDelete([mixed $id = null ]) : bool
Parameters
- $id : mixed = null
Return values
boolsoftDeletedQuery()
Get soft deleted query
public
softDeletedQuery() : QueryBuilder
Return values
QueryBuilderSUSPENDED()
Suspended
public
SUSPENDED() : int
Return values
intupdateLoginDate()
Set login date to current time
public
updateLoginDate() : bool
Return values
boolverifyEmail()
Get user by email
public
verifyEmail(string $email, int $id) : array<string|int, mixed>|false
Parameters
- $email : string
- $id : int
Return values
array<string|int, mixed>|falseverifyPassword()
Return true if password is correct.
public
verifyPassword(string $password) : bool
Parameters
- $password : string
Return values
boolverifyUserName()
Verify username
public
verifyUserName(string $userName, int $id) : bool
Parameters
- $userName : string
- $id : int
Return values
boolwhereIgnoreCase()
Where case insensitive
public
whereIgnoreCase(string $attribute, mixed $value[, string $operator = '=' ]) : Builder
Parameters
- $attribute : string
- $value : mixed
- $operator : string = '='