UserFrosting API

UserInterface

User Interface.

Represents a User object as stored in the database.

Table of Contents

activities() Get all activities for this user. HasMany
delete() Delete this user from the database, along with any linked roles and activities. bool
getCache() Return a cache instance specific to that user. Store
getFullNameAttribute() Allows you to get the full name of the user using `$user->full_name`. string
getCachedPermissions() Retrieve the cached permissions dictionary for this user. array
reloadCachedPermissions() Retrieve the cached permissions dictionary for this user. $this
getSecondsSinceLastActivity() Get the amount of time, in seconds, that has elapsed since the last activity of a certain time for this user. int
group() Return this user's group. BelongsTo
isMaster() Returns whether or not this user is the master user. bool
lastActivity() Get the most recent activity for this user, based on the user's last_activity_id. BelongsTo
lastActivityOfType() Find the most recent activity for this user of a particular type. Builder
lastActivityTime() Get the most recent time for a specified activity type for this user. string|null
onLogin() Performs tasks to be done after this user has been successfully authenticated. mixed
onLogout() Performs tasks to be done after this user has been logged out. mixed
passwordResets() Get all password reset requests for this user. HasMany
permissions() Get all of the permissions this user has, via its roles. BelongsToManyThrough
roles() Get all roles to which this user belongs. BelongsToMany
scopeForRole() Query scope to get all users who have a specific role. Builder
scopeJoinLastActivity() Joins the user's most recent activity directly, so we can do things like sort, search, paginate, etc. Builder

Methods

activities()

Get all activities for this user.

public activities( ) : HasMany
Return values
HasMany

delete()

Delete this user from the database, along with any linked roles and activities.

public delete( [ $hardDelete : bool = false ] ) : bool
Parameters
$hardDelete : bool = false

Set to true to completely remove the user and all associated objects.

Return values
bool

true if the deletion was successful, false otherwise.

getCache()

Return a cache instance specific to that user.

public getCache( ) : Store
Return values
Store

getFullNameAttribute()

Allows you to get the full name of the user using `$user->full_name`.

public getFullNameAttribute( ) : string
Return values
string

getCachedPermissions()

Retrieve the cached permissions dictionary for this user.

public getCachedPermissions( ) : array
Return values
array

reloadCachedPermissions()

Retrieve the cached permissions dictionary for this user.

public reloadCachedPermissions( ) : $this
Return values
$this

getSecondsSinceLastActivity()

Get the amount of time, in seconds, that has elapsed since the last activity of a certain time for this user.

public getSecondsSinceLastActivity( $type : string ) : int
Parameters
$type : string

The type of activity to search for.

Return values
int

group()

Return this user's group.

public group( ) : BelongsTo
Return values
BelongsTo

isMaster()

Returns whether or not this user is the master user.

public isMaster( ) : bool
Return values
bool

lastActivity()

Get the most recent activity for this user, based on the user's last_activity_id.

public lastActivity( ) : BelongsTo
Return values
BelongsTo

lastActivityOfType()

Find the most recent activity for this user of a particular type.

public lastActivityOfType( [ $type : string = null ] ) : Builder
Parameters
$type : string = null
Return values
Builder

lastActivityTime()

Get the most recent time for a specified activity type for this user.

public lastActivityTime( $type : string ) : string|null
Parameters
$type : string
Return values
string|null

The last activity time, as a SQL formatted time (YYYY-MM-DD HH:MM:SS), or null if an activity of this type doesn't exist.

onLogin()

Performs tasks to be done after this user has been successfully authenticated.

public onLogin( [ $params : array = [] ] ) : mixed

By default, adds a new sign-in activity and updates any legacy hash.

Parameters
$params : array = []

Optional array of parameters used for this event handler.

Tags
todo

Transition to Laravel Event dispatcher to handle this

Return values
mixed

onLogout()

Performs tasks to be done after this user has been logged out.

public onLogout( [ $params : array = [] ] ) : mixed

By default, adds a new sign-out activity.

Parameters
$params : array = []

Optional array of parameters used for this event handler.

Tags
todo

Transition to Laravel Event dispatcher to handle this

Return values
mixed

passwordResets()

Get all password reset requests for this user.

public passwordResets( ) : HasMany
Return values
HasMany

roles()

Get all roles to which this user belongs.

public roles( ) : BelongsToMany
Return values
BelongsToMany

scopeForRole()

Query scope to get all users who have a specific role.

public scopeForRole( $query : Builder , $roleId : int ) : Builder
Parameters
$query : Builder
$roleId : int
Return values
Builder

scopeJoinLastActivity()

Joins the user's most recent activity directly, so we can do things like sort, search, paginate, etc.

public scopeJoinLastActivity( $query : Builder ) : Builder
Parameters
$query : Builder
Return values
Builder

Search results