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 174
static void
setDisplayNameDriver(DriverInterface $driver)
at
line 182
static void
setAvatarDriver(DriverInterface $driver)
Set the avatar driver.
at
line 187
static void
setPasswordCheckers(array $checkers)
at
line 236
void
setPasswordAttribute(string|null $value)
Set the password attribute, storing it as a hash.
at
line 273
bool
getHasUploadedAvatarAttribute()
Determine whether the user has uploaded a custom avatar.
at
line 278
string|null
getAvatarUrlAttribute(string|null $value = null)
at
line 287
string
getDisplayNameAttribute()
at
line 292
bool
checkPassword(string $password)
at
line 322
bool
hasPermission(string $permission)
at
line 335
bool
hasPermissionLike(string $match)
Check whether the user has a permission that is like the given string, based on their groups.
at
line 354
array
getAlertableNotificationTypes()
Get the notification types that should be alerted to this user, according to their preferences.
at
line 361
int
getUnreadNotificationCount()
at
line 373
protected HasMany
unreadNotifications()
at
line 382
protected Collection
getUnreadNotifications()
at
line 390
int
getNewNotificationCount()
Get the number of new, unseen notifications for the user.
at
line 406
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 420
void
setPreferencesAttribute(array $value)
Encode an array of preferences for storage in the database.
at
line 429
bool
shouldAlert(string $type)
Check whether the user should receive an alert for a notification type.
at
line 438
bool
shouldEmail(string $type)
Check whether the user should receive an email for a notification type.
at
line 443
mixed
getPreference(string $key, mixed $default = null)
at
line 477
bool
isAdmin()
at
line 485
bool
isGuest()
Check whether the user is a guest.
at
line 500
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 516
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 526
void
assertCan(string $ability, mixed $arguments = null)
at
line 536
void
assertAdmin()
at
line 544
HasMany
posts()
at
line 552
HasMany
discussions()
at
line 560
BelongsToMany
read()
at
line 568
BelongsToMany
groups()
at
line 573
BelongsToMany
visibleGroups()
at
line 581
HasMany
notifications()
at
line 589
HasMany
emailTokens()
at
line 597
HasMany
passwordTokens()
at
line 606
Builder
permissions()
Define the relationship with the permissions of all the groups that the user is in.
at
line 630
array
getPermissions()
Get a list of permissions that the user has.
at
line 642
HasMany
accessTokens()
at
line 650
HasMany
loginProviders()
at
line 655
bool
can(string $ability, mixed $arguments = null)
at
line 660
bool
cannot(string $ability, mixed $arguments = null)
at
line 670
static void
setHasher(Hasher $hasher)
Set the hasher with which to hash passwords.
at
line 680
static void
registerPreference(string $key, callable|null $transformer = null, mixed $default = null)
Register a preference with a transformer and a default value.
at
line 690
static void
addGroupProcessor(callable $callback)
Register a callback that processes a user's list of groups.
at
line 699
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.