class User extends AbstractModel
Traits
Constants
| LAST_SEEN_UPDATE_DIFF |
Difference from the current `last_seen` attribute value before `updateLastSeen()` will update the attribute on the DB. Measured in seconds. |
Properties
| bool | $timestamps | Indicates if the model should be timestamped. Turn off by default. | from AbstractModel |
|
| protected callable[] | $afterSaveCallbacks | An array of callbacks to be run once after the model is saved. | from AbstractModel |
|
| protected callable[] | $afterDeleteCallbacks | An array of callbacks to be run once after the model is deleted. | from AbstractModel |
|
| static array | $customCasts | from AbstractModel |
|
|
| static array | $defaults | from AbstractModel |
|
|
| protected string|null | $tableAlias | An alias for the table name, used in queries. | from AbstractModel |
|
| string[]|null | $uniqueKeys | If a model has unique keys, they should be defined here. | from AbstractModel |
|
| protected array | $pendingEvents | from EventGeneratorTrait |
|
|
| static protected array | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected | $casts |
|
||
| protected string[]|null | $permissions | An array of permissions that this user has. |
|
|
| static protected callable[] | $groupProcessors | An array of callables, through each of which the user's list of groups is passed before being returned. |
|
|
| array | $preferences |
|
||
| static protected DriverInterface | $displayNameDriver | A driver for getting display names. |
|
|
| static protected DriverInterface | $avatarDriver | A driver for getting avatar URLs. |
|
|
| static protected Hasher | $hasher | The hasher with which to hash passwords. |
|
|
| static protected Gate | $gate | The access gate. |
|
|
| static protected callable[] | $passwordCheckers | Callbacks to check passwords. |
|
|
| int | $id |
|
||
| 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 |
|
||
| Group> | $groups |
|
||
| Group> | $visibleGroups |
|
||
| Notification> | $notifications |
|
||
| AccessToken> | $accessTokens |
|
||
| Post> | $posts |
|
||
| Discussion> | $discussions |
|
||
| Discussion> | $read |
|
||
| Notification> | $unreadNotifications |
|
||
| LoginProvider> | $loginProviders |
|
||
| EmailToken> | $emailTokens |
|
||
| PasswordToken> | $passwordTokens |
|
Methods
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
No description
Scope a query to only include records that are visible to a user.
Check whether the user has a permission that is like the given string, based on their groups.
Get the notification types that should be alerted to this user, according to their preferences.
Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.
Encode an array of preferences for storage in the database.
Check whether the user should receive an alert for a notification type.
Check whether the user should receive an email for a notification type.
Define the relationship with the permissions of all the groups that the user is in.
Register a preference with a transformer and a default value.
Register a callback that processes a user's list of groups.
Get the key for a preference which flags whether the user will receive a notification for $type via $method.
Set the value of a notification preference.
Details
at
line 145
static
boot()
in AbstractModel
at
line 88
__construct(array $attributes = [])
in AbstractModel
at
line 103
array
getCasts()
in AbstractModel
at
line 117
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 125
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 133
array
releaseAfterSaveCallbacks()
in AbstractModel
at
line 145
array
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 157
newModelQuery()
in AbstractModel
at
line 169
qualifyColumn($column)
in AbstractModel
at
line 178
mixed
withTableAlias(callable $callback)
in AbstractModel
at
line 191
Collection
newCollection(array $models = [])
in AbstractModel
at
line 197
__sleep()
in EventGeneratorTrait
at
line 16
void
raise(object $event)
in EventGeneratorTrait
at
line 24
array
releaseEvents()
Return and reset all pending events.
in ScopeVisibilityTrait
at
line 28
static void
registerVisibilityScoper(callable $scoper, string|null $ability = null)
in ScopeVisibilityTrait
at
line 44
Builder
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
Scope a query to only include records that are visible to a user.
in ScopeVisibilityTrait
at
line 19
static Builder
whereVisibleTo(User $user)
at
line 180
static void
setDisplayNameDriver(DriverInterface $driver)
at
line 188
static void
setAvatarDriver(DriverInterface $driver)
Set the avatar driver.
at
line 193
static void
setPasswordCheckers(array $checkers)
at
line 242
void
setPasswordAttribute(string|null $value)
Set the password attribute, storing it as a hash.
at
line 279
bool
getHasUploadedAvatarAttribute()
Determine whether the user has uploaded a custom avatar.
at
line 284
string|null
getAvatarUrlAttribute(string|null $value = null)
at
line 293
string|null
getAvatarSrcsetAttribute()
at
line 304
string
getDisplayNameAttribute()
at
line 309
bool
checkPassword(string $password)
at
line 339
bool
hasPermission(string $permission)
at
line 352
bool
hasPermissionLike(string $match)
Check whether the user has a permission that is like the given string, based on their groups.
at
line 371
array
getAlertableNotificationTypes()
Get the notification types that should be alerted to this user, according to their preferences.
at
line 378
int
getUnreadNotificationCount()
at
line 390
protected HasMany
unreadNotifications()
at
line 399
protected Collection
getUnreadNotifications()
at
line 407
int
getNewNotificationCount()
Get the number of new, unseen notifications for the user.
at
line 423
array
getPreferencesAttribute(string|null $value)
Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.
at
line 437
void
setPreferencesAttribute(array $value)
Encode an array of preferences for storage in the database.
at
line 446
bool
shouldAlert(string $type)
Check whether the user should receive an alert for a notification type.
at
line 455
bool
shouldEmail(string $type)
Check whether the user should receive an email for a notification type.
at
line 460
mixed
getPreference(string $key, mixed $default = null)
at
line 494
bool
isAdmin()
at
line 502
bool
isGuest()
Check whether the user is a guest.
at
line 517
void
assertPermission(bool $condition)
Ensure the current user is allowed to do something.
If the condition is not met, an exception will be thrown that signals the lack of permissions. This is about *authorization*, i.e. retrying such a request / operation without a change in permissions (or using another user account) is pointless.
at
line 533
void
assertRegistered()
Ensure the given actor is authenticated.
This will throw an exception for guest users, signaling that *authorization* failed. Thus, they could retry the operation after logging in (or using other means of authentication).
at
line 543
void
assertCan(string $ability, mixed $arguments = null)
at
line 553
void
assertAdmin()
at
line 561
HasMany
posts()
at
line 569
HasMany
discussions()
at
line 577
BelongsToMany
read()
at
line 585
BelongsToMany
groups()
at
line 590
BelongsToMany
visibleGroups()
at
line 598
HasMany
notifications()
at
line 606
HasMany
emailTokens()
at
line 614
HasMany
passwordTokens()
at
line 623
Builder
permissions()
Define the relationship with the permissions of all the groups that the user is in.
at
line 647
array
getPermissions()
Get a list of permissions that the user has.
at
line 659
HasMany
accessTokens()
at
line 667
HasMany
loginProviders()
at
line 672
bool
can(string $ability, mixed $arguments = null)
at
line 677
bool
cannot(string $ability, mixed $arguments = null)
at
line 687
static void
setHasher(Hasher $hasher)
Set the hasher with which to hash passwords.
at
line 697
static void
registerPreference(string $key, callable|null $transformer = null, mixed $default = null)
Register a preference with a transformer and a default value.
at
line 707
static void
addGroupProcessor(callable $callback)
Register a callback that processes a user's list of groups.
at
line 716
static string
getNotificationPreferenceKey(string $type, string $method)
Get the key for a preference which flags whether the user will receive a notification for $type via $method.