class Guest extends User

Traits

Properties

bool $timestamps <p>Indicates if the model should be timestamped. Turn off by default.</p> from AbstractModel
protected callable[] $afterSaveCallbacks <p>An array of callbacks to be run once after the model is saved.</p> from AbstractModel
protected callable[] $afterDeleteCallbacks <p>An array of callbacks to be run once after the model is deleted.</p> from AbstractModel
static $customRelations from AbstractModel
static $dateAttributes from AbstractModel
static $defaults from AbstractModel
protected array $pendingEvents from EventGeneratorTrait
static protected $visibilityScopers from ScopeVisibilityTrait
protected array $dates <p>The attributes that should be mutated to dates.</p> from User
protected string[]|null $permissions <p>An array of permissions that this user has.</p> from User
protected Session $session from User
static protected $groupProcessors <p>An array of callables, through each of which the user's list of groups is passed before being returned.</p> from User
array $preferences from User
static protected DriverInterface $displayNameDriver <p>A driver for getting display names.</p> from User
static protected Hasher $hasher <p>The hasher with which to hash passwords.</p> from User
static protected Gate $gate <p>The access gate.</p> from User
int $id <p>Override the ID of this user, as a guest does not have an ID.</p>
string $username from User
string $display_name from User
string $email from User
bool $is_email_confirmed from User
string $password from User
string|null $avatar_url from User
Carbon|null $joined_at from User
Carbon|null $last_seen_at from User
Carbon|null $marked_all_as_read_at from User
Carbon|null $read_notifications_at from User
int $discussion_count from User
int $comment_count from User

Methods

static 
boot()

<p>Boot the model.</p>

from User
__construct(array $attributes = [])

<p>{@inheritdoc}</p>

array
getDates()

<p>Get the attributes that should be converted to dates.</p>

mixed
getAttribute(string $key)

<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>

mixed
getCustomRelation(string $name)

<p>Get a custom relation object.</p>

void
afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

void
afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

callable[]
releaseAfterSaveCallbacks()

No description

callable[]
releaseAfterDeleteCallbacks()

No description

__call($method, $arguments)

<p>{@inheritdoc}</p>

raise(mixed $event)

<p>Raise a new event.</p>

array
releaseEvents()

<p>Return and reset all pending events.</p>

static 
registerVisibilityScoper($scoper, $ability = null)

No description

scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')

<p>Scope a query to only include records that are visible to a user.</p>

static User
register(string $username, string $email, string $password)

<p>Register a new user.</p>

from User
static 
setGate(Gate $gate)

No description

from User
static 
setDisplayNameDriver(DriverInterface $driver)

<p>Set the display name driver.</p>

from User
$this
rename(string $username)

<p>Rename the user.</p>

from User
$this
changeEmail(string $email)

<p>Change the user's email.</p>

from User
$this
requestEmailChange(string $email)

<p>Request that the user's email be changed.</p>

from User
$this
changePassword(string $password)

<p>Change the user's password.</p>

from User
setPasswordAttribute(string $value)

<p>Set the password attribute, storing it as a hash.</p>

from User
$this
markAllAsRead()

<p>Mark all discussions as read.</p>

from User
$this
markNotificationsAsRead()

<p>Mark all notifications as read.</p>

from User
$this
changeAvatarPath(string $path)

<p>Change the path of the user avatar.</p>

from User
string
getAvatarUrlAttribute(string $value = null)

<p>Get the URL of the user's avatar.</p>

from User
string
getDisplayNameAttribute()

<p>Get the user's display name.</p>

from User
bool
checkPassword(string $password)

<p>Check if a given password matches the user's password.</p>

from User
$this
activate()

<p>Activate the user's account.</p>

from User
bool
hasPermission(string $permission)

<p>Check whether the user has a certain permission based on their groups.</p>

from User
bool
hasPermissionLike(string $match)

<p>Check whether the user has a permission that is like the given string, based on their groups.</p>

from User
array
getAlertableNotificationTypes()

<p>Get the notification types that should be alerted to this user, according to their preferences.</p>

from User
int
getUnreadNotificationCount()

<p>Get the number of unread notifications for the user.</p>

from User
Collection
getUnreadNotifications()

<p>Get all notifications that have not been read yet.</p>

from User
int
getNewNotificationCount()

<p>Get the number of new, unseen notifications for the user.</p>

from User
array
getPreferencesAttribute(string $value)

<p>Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.</p>

from User
setPreferencesAttribute(mixed $value)

<p>Encode an array of preferences for storage in the database.</p>

from User
bool
shouldAlert(string $type)

<p>Check whether or not the user should receive an alert for a notification type.</p>

from User
bool
shouldEmail(string $type)

<p>Check whether or not the user should receive an email for a notification type.</p>

from User
mixed
getPreference(string $key, mixed $default = null)

<p>Get the value of a preference for this user.</p>

from User
$this
setPreference(string $key, mixed $value)

<p>Set the value of a preference for this user.</p>

from User
$this
updateLastSeen()

<p>Set the user as being last seen just now.</p>

from User
bool
isAdmin()

<p>Check whether or not the user is an administrator.</p>

from User
bool
isGuest()

<p>Check whether or not the user is a guest.</p>

assertPermission(bool $condition)

<p>Ensure the current user is allowed to do something.</p>

from User
assertRegistered()

<p>Ensure the given actor is authenticated.</p>

from User
assertCan(string $ability, mixed $arguments = null)

No description

from User
assertAdmin()

No description

from User
HasMany
posts()

<p>Define the relationship with the user's posts.</p>

from User
HasMany
discussions()

<p>Define the relationship with the user's discussions.</p>

from User
BelongsTo
read()

<p>Define the relationship with the user's read discussions.</p>

from User
BelongsToMany
groups()

<p>Define the relationship with the user's groups.</p>

from User
visibleGroups()

No description

from User
HasMany
notifications()

<p>Define the relationship with the user's notifications.</p>

from User
HasMany
emailTokens()

<p>Define the relationship with the user's email tokens.</p>

from User
Builder
permissions()

<p>Define the relationship with the permissions of all of the groups that the user is in.</p>

from User
string[]
getPermissions()

<p>Get a list of permissions that the user has.</p>

from User
HasMany
accessTokens()

<p>Define the relationship with the user's access tokens.</p>

from User
loginProviders()

<p>Get the user's login providers.</p>

from User
bool
can(string $ability, array|mixed $arguments = null)

No description

from User
bool
cannot(string $ability, array|mixed $arguments = null)

No description

from User
Session
getSession()

No description

from User
setSession(Session $session)

No description

from User
static 
setHasher(Hasher $hasher)

<p>Set the hasher with which to hash passwords.</p>

from User
static 
addPreference(string $key, callable $transformer = null, mixed $default = null) deprecated

No description

from User
static 
registerPreference(string $key, callable $transformer = null, mixed $default = null)

<p>Register a preference with a transformer and a default value.</p>

from User
static array
addGroupProcessor(callable $callback)

<p>Register a callback that processes a user's list of groups.</p>

from User
static string
getNotificationPreferenceKey(string $type, string $method)

<p>Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.</p>

from User
$this
refreshCommentCount()

<p>Refresh the user's comments count.</p>

from User
$this
refreshDiscussionCount()

<p>Refresh the user's comments count.</p>

from User
getGroupsAttribute()

<p>Get the guest's group, containing only the 'guests' group model.</p>

Details

static boot()

<p>Boot the model.</p>

__construct(array $attributes = [])

<p>{@inheritdoc}</p>

Parameters

array $attributes

array getDates()

<p>Get the attributes that should be converted to dates.</p>

Return Value

array

mixed getAttribute(string $key)

<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>

Parameters

string $key

Return Value

mixed

protected mixed getCustomRelation(string $name)

<p>Get a custom relation object.</p>

Parameters

string $name

Return Value

mixed

void afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

Parameters

callable $callback

Return Value

void

void afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

Parameters

callable $callback

Return Value

void

callable[] releaseAfterSaveCallbacks()

Return Value

callable[]

callable[] releaseAfterDeleteCallbacks()

Return Value

callable[]

__call($method, $arguments)

<p>{@inheritdoc}</p>

Parameters

$method
$arguments

raise(mixed $event)

<p>Raise a new event.</p>

Parameters

mixed $event

array releaseEvents()

<p>Return and reset all pending events.</p>

Return Value

array

static registerVisibilityScoper($scoper, $ability = null)

Parameters

$scoper
$ability

scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')

<p>Scope a query to only include records that are visible to a user.</p>

Parameters

Builder $query
User $actor
string $ability

static User register(string $username, string $email, string $password)

<p>Register a new user.</p>

Parameters

string $username
string $email
string $password

Return Value

User

static setGate(Gate $gate)

Parameters

Gate $gate

static setDisplayNameDriver(DriverInterface $driver)

<p>Set the display name driver.</p>

Parameters

DriverInterface $driver

$this rename(string $username)

<p>Rename the user.</p>

Parameters

string $username

Return Value

$this

$this changeEmail(string $email)

<p>Change the user's email.</p>

Parameters

string $email

Return Value

$this

$this requestEmailChange(string $email)

<p>Request that the user's email be changed.</p>

Parameters

string $email

Return Value

$this

$this changePassword(string $password)

<p>Change the user's password.</p>

Parameters

string $password

Return Value

$this

setPasswordAttribute(string $value)

<p>Set the password attribute, storing it as a hash.</p>

Parameters

string $value

$this markAllAsRead()

<p>Mark all discussions as read.</p>

Return Value

$this

$this markNotificationsAsRead()

<p>Mark all notifications as read.</p>

Return Value

$this

$this changeAvatarPath(string $path)

<p>Change the path of the user avatar.</p>

Parameters

string $path

Return Value

$this

string getAvatarUrlAttribute(string $value = null)

<p>Get the URL of the user's avatar.</p>

Parameters

string $value

Return Value

string

string getDisplayNameAttribute()

<p>Get the user's display name.</p>

Return Value

string

bool checkPassword(string $password)

<p>Check if a given password matches the user's password.</p>

Parameters

string $password

Return Value

bool

$this activate()

<p>Activate the user's account.</p>

Return Value

$this

bool hasPermission(string $permission)

<p>Check whether the user has a certain permission based on their groups.</p>

Parameters

string $permission

Return Value

bool

bool hasPermissionLike(string $match)

<p>Check whether the user has a permission that is like the given string, based on their groups.</p>

Parameters

string $match

Return Value

bool

array getAlertableNotificationTypes()

<p>Get the notification types that should be alerted to this user, according to their preferences.</p>

Return Value

array

int getUnreadNotificationCount()

<p>Get the number of unread notifications for the user.</p>

Return Value

int

protected Collection getUnreadNotifications()

<p>Get all notifications that have not been read yet.</p>

Return Value

Collection

int getNewNotificationCount()

<p>Get the number of new, unseen notifications for the user.</p>

Return Value

int

array getPreferencesAttribute(string $value)

<p>Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.</p>

Parameters

string $value

Return Value

array

setPreferencesAttribute(mixed $value)

<p>Encode an array of preferences for storage in the database.</p>

Parameters

mixed $value

bool shouldAlert(string $type)

<p>Check whether or not the user should receive an alert for a notification type.</p>

Parameters

string $type

Return Value

bool

bool shouldEmail(string $type)

<p>Check whether or not the user should receive an email for a notification type.</p>

Parameters

string $type

Return Value

bool

mixed getPreference(string $key, mixed $default = null)

<p>Get the value of a preference for this user.</p>

Parameters

string $key
mixed $default

Return Value

mixed

$this setPreference(string $key, mixed $value)

<p>Set the value of a preference for this user.</p>

Parameters

string $key
mixed $value

Return Value

$this

$this updateLastSeen()

<p>Set the user as being last seen just now.</p>

Return Value

$this

bool isAdmin()

<p>Check whether or not the user is an administrator.</p>

Return Value

bool

bool isGuest()

<p>Check whether or not the user is a guest.</p>

Return Value

bool

assertPermission(bool $condition)

<p>Ensure the current user is allowed to do something.</p>

<p>If the condition is not met, an exception will be thrown that signals the lack of permissions. This is about <em>authorization</em>, i.e. retrying such a request / operation without a change in permissions (or using another user account) is pointless.</p>

Parameters

bool $condition

Exceptions

PermissionDeniedException

assertRegistered()

<p>Ensure the given actor is authenticated.</p>

<p>This will throw an exception for guest users, signaling that <em>authorization</em> failed. Thus, they could retry the operation after logging in (or using other means of authentication).</p>

assertCan(string $ability, mixed $arguments = null)

Parameters

string $ability
mixed $arguments

Exceptions

PermissionDeniedException

assertAdmin()

HasMany posts()

<p>Define the relationship with the user's posts.</p>

Return Value

HasMany

HasMany discussions()

<p>Define the relationship with the user's discussions.</p>

Return Value

HasMany

BelongsTo read()

<p>Define the relationship with the user's read discussions.</p>

Return Value

BelongsTo

BelongsToMany groups()

<p>Define the relationship with the user's groups.</p>

Return Value

BelongsToMany

visibleGroups()

HasMany notifications()

<p>Define the relationship with the user's notifications.</p>

Return Value

HasMany

HasMany emailTokens()

<p>Define the relationship with the user's email tokens.</p>

Return Value

HasMany

Builder permissions()

<p>Define the relationship with the permissions of all of the groups that the user is in.</p>

Return Value

Builder

string[] getPermissions()

<p>Get a list of permissions that the user has.</p>

Return Value

string[]

HasMany accessTokens()

<p>Define the relationship with the user's access tokens.</p>

Return Value

HasMany

loginProviders()

<p>Get the user's login providers.</p>

bool can(string $ability, array|mixed $arguments = null)

Parameters

string $ability
array|mixed $arguments

Return Value

bool

bool cannot(string $ability, array|mixed $arguments = null)

Parameters

string $ability
array|mixed $arguments

Return Value

bool

Session getSession()

Return Value

Session

setSession(Session $session)

Parameters

Session $session

static setHasher(Hasher $hasher)

<p>Set the hasher with which to hash passwords.</p>

Parameters

Hasher $hasher

static addPreference(string $key, callable $transformer = null, mixed $default = null) deprecated

deprecated beta 15, remove beta 16. Use `registerPreference` instead. Register a preference with a transformer and a default value.

Parameters

string $key
callable $transformer
mixed $default

static registerPreference(string $key, callable $transformer = null, mixed $default = null)

<p>Register a preference with a transformer and a default value.</p>

Parameters

string $key
callable $transformer
mixed $default

static array addGroupProcessor(callable $callback)

<p>Register a callback that processes a user's list of groups.</p>

Parameters

callable $callback

Return Value

array <p>$groupIds</p>

static string getNotificationPreferenceKey(string $type, string $method)

<p>Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.</p>

Parameters

string $type
string $method

Return Value

string

$this refreshCommentCount()

<p>Refresh the user's comments count.</p>

Return Value

$this

$this refreshDiscussionCount()

<p>Refresh the user's comments count.</p>

Return Value

$this

Group getGroupsAttribute()

<p>Get the guest's group, containing only the 'guests' group model.</p>

Return Value

Group