class Guest extends User

Traits

Constants

LAST_SEEN_UPDATE_DIFF

<p>Difference from the current <code>last_seen</code> attribute value before <code>updateLastSeen()</code> will update the attribute on the DB. Measured in seconds.</p>

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 $customCasts from AbstractModel
static $defaults from AbstractModel
protected $tableAlias <p>An alias for the table name, used in queries.</p> from AbstractModel
protected $pendingEvents from EventGeneratorTrait
static protected $visibilityScopers from ScopeVisibilityTrait
protected $casts from User
protected string[]|null $permissions <p>An array of permissions that this user has.</p> from User
static protected callable[] $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 $displayNameDriver <p>A driver for getting display names.</p> from User
static protected $hasher <p>The hasher with which to hash passwords.</p> from User
static protected $gate <p>The access gate.</p> from User
static protected callable[] $passwordCheckers <p>Callbacks to check passwords.</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
Group> $groups from User
Group> $visibleGroups from User
Notification> $notifications from User
AccessToken> $accessTokens from User
Post> $posts from User
Discussion> $discussions from User
Discussion> $read from User
Notification> $unreadNotifications from User
LoginProvider> $loginProviders from User
EmailToken> $emailTokens from User
PasswordToken> $passwordTokens from User

Methods

static 
boot()

No description

from User
__construct(array $attributes = [])

No description

array
getCasts()

No description

getAttribute($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>

array
releaseAfterSaveCallbacks()

No description

array
releaseAfterDeleteCallbacks()

No description

__call($method, $parameters)

No description

newModelQuery()

No description

qualifyColumn($column)

No description

mixed
withTableAlias(callable $callback)

No description

newCollection(array $models = [])

No description

__sleep()

No description

void
raise(object $event)

No description

array
releaseEvents()

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

static void
registerVisibilityScoper(callable $scoper, string|null $ability = null)

No description

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

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

static Builder
whereVisibleTo(User $user)

No description

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

No description

from User
static void
setGate(Gate $gate)

No description

from User
static void
setDisplayNameDriver(DriverInterface $driver)

No description

from User
static void
setPasswordCheckers(array $checkers)

No description

from User
rename(string $username)

No description

from User
changeEmail(string $email)

No description

from User
requestEmailChange(string $email)

No description

from User
changePassword(string $password)

No description

from User
void
setPasswordAttribute(string|null $value)

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

from User
markAllAsRead()

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

from User
markNotificationsAsRead()

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

from User
changeAvatarPath(string|null $path)

No description

from User
string|null
getAvatarUrlAttribute(string|null $value = null)

No description

from User
string
getDisplayNameAttribute()

No description

from User
bool
checkPassword(string $password)

No description

from User
activate()

No description

from User
bool
hasPermission(string $permission)

No description

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()

No description

from User
HasMany
unreadNotifications()

No description

from User
Collection
getUnreadNotifications()

No description

from User
int
getNewNotificationCount()

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

from User
array
getPreferencesAttribute(string|null $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
void
setPreferencesAttribute(array $value)

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

from User
bool
shouldAlert(string $type)

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

from User
bool
shouldEmail(string $type)

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

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

No description

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

No description

from User
updateLastSeen()

No description

from User
bool
isAdmin()

No description

from User
bool
isGuest()

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

void
assertPermission(bool $condition)

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

from User
void
assertRegistered()

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

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

No description

from User
void
assertAdmin()

No description

from User
HasMany
posts()

No description

from User
HasMany
discussions()

No description

from User
BelongsToMany
read()

No description

from User
BelongsToMany
groups()

No description

from User
BelongsToMany
visibleGroups()

No description

from User
HasMany
notifications()

No description

from User
HasMany
emailTokens()

No description

from User
HasMany
passwordTokens()

No description

from User
Builder
permissions()

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

from User
array
getPermissions()

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

from User
HasMany
accessTokens()

No description

from User
HasMany
loginProviders()

No description

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

No description

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

No description

from User
static void
setHasher(Hasher $hasher)

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

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

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

from User
static void
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 the user will receive a notification for $type via $method.</p>

from User
refreshCommentCount()

No description

from User
refreshDiscussionCount()

No description

from User
setNotificationPreference(string $type, string $method, bool $value)

<p>Set the value of a notification preference.</p>

from User
Collection
getGroupsAttribute()

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

Details

static boot()

__construct(array $attributes = [])

Parameters

array $attributes

array getCasts()

Return Value

array

getAttribute($key)

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

Parameters

$key

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

array releaseAfterSaveCallbacks()

Return Value

array

array releaseAfterDeleteCallbacks()

Return Value

array

__call($method, $parameters)

Parameters

$method
$parameters

newModelQuery()

qualifyColumn($column)

Parameters

$column

mixed withTableAlias(callable $callback)

Parameters

callable $callback

Return Value

mixed

Collection newCollection(array $models = [])

Parameters

array $models

Return Value

Collection

__sleep()

void raise(object $event)

Parameters

object $event

Return Value

void

array releaseEvents()

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

Return Value

array

static void registerVisibilityScoper(callable $scoper, string|null $ability = null)

Parameters

callable $scoper
string|null $ability

Return Value

void

Builder 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

Return Value

Builder

static Builder whereVisibleTo(User $user)

Parameters

User $user

Return Value

Builder

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

Parameters

string|null $username
string|null $email
string|null $password

Return Value

User

static void setGate(Gate $gate)

Parameters

Gate $gate

Return Value

void

static void setDisplayNameDriver(DriverInterface $driver)

Parameters

DriverInterface $driver

Return Value

void

static void setPasswordCheckers(array $checkers)

Parameters

array $checkers

Return Value

void

User rename(string $username)

Parameters

string $username

Return Value

User

User changeEmail(string $email)

Parameters

string $email

Return Value

User

User requestEmailChange(string $email)

Parameters

string $email

Return Value

User

User changePassword(string $password)

Parameters

string $password

Return Value

User

void setPasswordAttribute(string|null $value)

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

Parameters

string|null $value

Return Value

void

User markAllAsRead()

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

Return Value

User

User markNotificationsAsRead()

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

Return Value

User

User changeAvatarPath(string|null $path)

Parameters

string|null $path

Return Value

User

string|null getAvatarUrlAttribute(string|null $value = null)

Parameters

string|null $value

Return Value

string|null

string getDisplayNameAttribute()

Return Value

string

bool checkPassword(string $password)

Parameters

string $password

Return Value

bool

User activate()

Return Value

User

bool hasPermission(string $permission)

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()

Return Value

int

protected HasMany unreadNotifications()

Return Value

HasMany

protected Collection getUnreadNotifications()

Return Value

Collection

int getNewNotificationCount()

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

Return Value

int

array getPreferencesAttribute(string|null $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|null $value

Return Value

array

void setPreferencesAttribute(array $value)

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

Parameters

array $value

Return Value

void

bool shouldAlert(string $type)

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

Parameters

string $type

Return Value

bool

bool shouldEmail(string $type)

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

Parameters

string $type

Return Value

bool

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

Parameters

string $key
mixed $default

Return Value

mixed

User setPreference(string $key, mixed $value)

Parameters

string $key
mixed $value

Return Value

User

User updateLastSeen()

Return Value

User

bool isAdmin()

Return Value

bool

bool isGuest()

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

Return Value

bool

void 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

Return Value

void

Exceptions

PermissionDeniedException

void 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>

Return Value

void

Exceptions

NotAuthenticatedException

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

Parameters

string $ability
mixed $arguments

Return Value

void

Exceptions

PermissionDeniedException

void assertAdmin()

Return Value

void

Exceptions

PermissionDeniedException

HasMany posts()

Return Value

HasMany

HasMany discussions()

Return Value

HasMany

BelongsToMany read()

Return Value

BelongsToMany

BelongsToMany groups()

Return Value

BelongsToMany

BelongsToMany visibleGroups()

Return Value

BelongsToMany

HasMany notifications()

Return Value

HasMany

HasMany emailTokens()

Return Value

HasMany

HasMany passwordTokens()

Return Value

HasMany

Builder permissions()

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

Return Value

Builder

array getPermissions()

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

Return Value

array

HasMany accessTokens()

Return Value

HasMany

HasMany loginProviders()

Return Value

HasMany

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

Parameters

string $ability
mixed $arguments

Return Value

bool

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

Parameters

string $ability
mixed $arguments

Return Value

bool

static void setHasher(Hasher $hasher)

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

Parameters

Hasher $hasher

Return Value

void

static void 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

Return Value

void

static void addGroupProcessor(callable $callback)

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

Parameters

callable $callback

Return Value

void

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

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

Parameters

string $type
string $method

Return Value

string

User refreshCommentCount()

Return Value

User

User refreshDiscussionCount()

Return Value

User

User setNotificationPreference(string $type, string $method, bool $value)

<p>Set the value of a notification preference.</p>

Parameters

string $type
string $method
bool $value

Return Value

User

Collection getGroupsAttribute()

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

Return Value

Collection