class User extends AbstractModel
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 string|null | $tableAlias | <p>An alias for the table name, used in queries.</p> | from AbstractModel | |
int | $id | |||
protected array | $pendingEvents | from EventGeneratorTrait | ||
static protected | $visibilityScopers | from ScopeVisibilityTrait | ||
protected array | $dates | <p>The attributes that should be mutated to dates.</p> | ||
protected string[]|null | $permissions | <p>An array of permissions that this user has.</p> | ||
static protected | $groupProcessors | <p>An array of callables, through each of which the user's list of groups is passed before being returned.</p> | ||
array | $preferences | |||
static protected DriverInterface | $displayNameDriver | <p>A driver for getting display names.</p> | ||
static protected Hasher | $hasher | <p>The hasher with which to hash passwords.</p> | ||
static protected Gate | $gate | <p>The access gate.</p> | ||
static protected array | $passwordCheckers | <p>Callbacks to check passwords.</p> | ||
string | $username | |||
string | $display_name | |||
string | ||||
bool | $is_email_confirmed | |||
string | $password | |||
string|null | $avatar_url | |||
Carbon|null | $joined_at | |||
Carbon|null | $last_seen_at | |||
Carbon|null | $marked_all_as_read_at | |||
Carbon|null | $read_notifications_at | |||
int | $discussion_count | |||
int | $comment_count |
Methods
<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>
<p>Register a callback to be run once after the model is saved.</p>
<p>Register a callback to be run once after the model is deleted.</p>
<p>Scope a query to only include records that are visible to a user.</p>
<p>Check whether the user has a certain permission based on their groups.</p>
<p>Check whether the user has a permission that is like the given string, based on their groups.</p>
<p>Get the notification types that should be alerted to this user, according to their preferences.</p>
<p>Return query builder for all notifications that have not been read yet.</p>
<p>Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.</p>
<p>Encode an array of preferences for storage in the database.</p>
<p>Check whether or not the user should receive an alert for a notification type.</p>
<p>Check whether or not the user should receive an email for a notification type.</p>
<p>Get the value of a preference for this user.</p>
<p>Define the relationship with the permissions of all of the groups that the user is in.</p>
<p>Register a preference with a transformer and a default value.</p>
<p>Register a callback that processes a user's list of groups.</p>
<p>Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.</p>
Details
at
line 136
static
boot()
<p>Boot the model.</p>
in AbstractModel
at
line 97
__construct(array $attributes = [])
<p>{@inheritdoc}</p>
in AbstractModel
at
line 115
getCasts()
<p>{@inheritdoc}</p>
in AbstractModel
at
line 133
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>
in AbstractModel
at
line 159
protected mixed
getCustomRelation(string $name)
<p>Get a custom relation object.</p>
in AbstractModel
at
line 175
void
afterSave(callable $callback)
<p>Register a callback to be run once after the model is saved.</p>
in AbstractModel
at
line 186
void
afterDelete(callable $callback)
<p>Register a callback to be run once after the model is deleted.</p>
in AbstractModel
at
line 194
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 206
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 218
__call($method, $arguments)
<p>{@inheritdoc}</p>
in AbstractModel
at
line 227
newModelQuery()
in AbstractModel
at
line 238
qualifyColumn($column)
in AbstractModel
at
line 247
withTableAlias(callable $callback)
in AbstractModel
at
line 262
newCollection(Collection|array $models = [])
in EventGeneratorTrait
at
line 24
raise(mixed $event)
<p>Raise a new event.</p>
in EventGeneratorTrait
at
line 34
array
releaseEvents()
<p>Return and reset all pending events.</p>
in ScopeVisibilityTrait
at
line 20
static
registerVisibilityScoper($scoper, $ability = null)
in ScopeVisibilityTrait
at
line 41
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
<p>Scope a query to only include records that are visible to a user.</p>
at
line 162
static User
register(string $username, string $email, string $password)
<p>Register a new user.</p>
at
line 189
static
setDisplayNameDriver(DriverInterface $driver)
<p>Set the display name driver.</p>
at
line 194
static
setPasswordCheckers(array $checkers)
at
line 205
$this
rename(string $username)
<p>Rename the user.</p>
at
line 223
$this
changeEmail(string $email)
<p>Change the user's email.</p>
at
line 240
$this
requestEmailChange(string $email)
<p>Request that the user's email be changed.</p>
at
line 255
$this
changePassword(string $password)
<p>Change the user's password.</p>
at
line 269
setPasswordAttribute(string $value)
<p>Set the password attribute, storing it as a hash.</p>
at
line 279
$this
markAllAsRead()
<p>Mark all discussions as read.</p>
at
line 291
$this
markNotificationsAsRead()
<p>Mark all notifications as read.</p>
at
line 304
$this
changeAvatarPath(string|null $path)
<p>Change the path of the user avatar.</p>
at
line 319
string
getAvatarUrlAttribute(string $value = null)
<p>Get the URL of the user's avatar.</p>
at
line 333
string
getDisplayNameAttribute()
<p>Get the user's display name.</p>
at
line 344
bool
checkPassword(string $password)
<p>Check if a given password matches the user's password.</p>
at
line 366
$this
activate()
<p>Activate the user's account.</p>
at
line 383
bool
hasPermission(string $permission)
<p>Check whether the user has a certain permission based on their groups.</p>
at
line 399
bool
hasPermissionLike(string $match)
<p>Check whether the user has a permission that is like the given string, based on their groups.</p>
at
line 420
array
getAlertableNotificationTypes()
<p>Get the notification types that should be alerted to this user, according to their preferences.</p>
at
line 432
int
getUnreadNotificationCount()
<p>Get the number of unread notifications for the user.</p>
at
line 442
protected HasMany
unreadNotifications()
<p>Return query builder for all notifications that have not been read yet.</p>
at
line 456
protected Collection
getUnreadNotifications()
<p>Get all notifications that have not been read yet.</p>
at
line 466
int
getNewNotificationCount()
<p>Get the number of new, unseen notifications for the user.</p>
at
line 480
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>
at
line 496
setPreferencesAttribute(mixed $value)
<p>Encode an array of preferences for storage in the database.</p>
at
line 508
bool
shouldAlert(string $type)
<p>Check whether or not the user should receive an alert for a notification type.</p>
at
line 520
bool
shouldEmail(string $type)
<p>Check whether or not the user should receive an email for a notification type.</p>
at
line 532
mixed
getPreference(string $key, mixed $default = null)
<p>Get the value of a preference for this user.</p>
at
line 544
$this
setPreference(string $key, mixed $value)
<p>Set the value of a preference for this user.</p>
at
line 566
$this
updateLastSeen()
<p>Set the user as being last seen just now.</p>
at
line 582
bool
isAdmin()
<p>Check whether or not the user is an administrator.</p>
at
line 592
bool
isGuest()
<p>Check whether or not the user is a guest.</p>
at
line 608
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>
at
line 624
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>
at
line 636
assertCan(string $ability, mixed $arguments = null)
at
line 646
assertAdmin()
at
line 656
HasMany
posts()
<p>Define the relationship with the user's posts.</p>
at
line 666
HasMany
discussions()
<p>Define the relationship with the user's discussions.</p>
at
line 676
Discussion>
read()
<p>Define the relationship with the user's read discussions.</p>
at
line 686
BelongsToMany
groups()
<p>Define the relationship with the user's groups.</p>
at
line 691
visibleGroups()
at
line 701
HasMany
notifications()
<p>Define the relationship with the user's notifications.</p>
at
line 711
HasMany
emailTokens()
<p>Define the relationship with the user's email tokens.</p>
at
line 721
HasMany
passwordTokens()
<p>Define the relationship with the user's email tokens.</p>
at
line 732
Builder
permissions()
<p>Define the relationship with the permissions of all of the groups that the user is in.</p>
at
line 756
string[]
getPermissions()
<p>Get a list of permissions that the user has.</p>
at
line 770
HasMany
accessTokens()
<p>Define the relationship with the user's access tokens.</p>
at
line 778
loginProviders()
<p>Get the user's login providers.</p>
at
line 788
bool
can(string $ability, array|mixed $arguments = null)
at
line 798
bool
cannot(string $ability, array|mixed $arguments = null)
at
line 810
static
setHasher(Hasher $hasher)
<p>Set the hasher with which to hash passwords.</p>
at
line 824
static
registerPreference(string $key, callable $transformer = null, mixed $default = null)
<p>Register a preference with a transformer and a default value.</p>
at
line 837
static void
addGroupProcessor(callable $callback)
<p>Register a callback that processes a user's list of groups.</p>
at
line 850
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>
at
line 860
$this
refreshCommentCount()
<p>Refresh the user's comments count.</p>
at
line 875
$this
refreshDiscussionCount()
<p>Refresh the user's comments count.</p>