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 | $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 | |||
protected string[]|null | $permissions | <p>An array of permissions that this user has.</p> | ||
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> | ||
array | $preferences | |||
static protected | $displayNameDriver | <p>A driver for getting display names.</p> | ||
static protected | $hasher | <p>The hasher with which to hash passwords.</p> | ||
static protected | $gate | <p>The access gate.</p> | ||
static protected callable[] | $passwordCheckers | <p>Callbacks to check passwords.</p> | ||
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
<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>
No description
<p>Scope a query to only include records that are visible to a user.</p>
No description
<p>Set the password attribute, storing it as a hash.</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>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 the user should receive an alert for a notification type.</p>
<p>Check whether the user should receive an email for a notification type.</p>
<p>Define the relationship with the permissions of all 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 the user will receive a notification for $type via $method.</p>
<p>Set the value of a notification preference.</p>
Details
at
line 139
static
boot()
in AbstractModel
at
line 88
__construct(array $attributes = [])
in AbstractModel
at
line 103
array
getCasts()
in AbstractModel
at
line 118
getAttribute($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 143
protected mixed
getCustomRelation(string $name)
<p>Get a custom relation object.</p>
in AbstractModel
at
line 158
void
afterSave(callable $callback)
<p>Register a callback to be run once after the model is saved.</p>
in AbstractModel
at
line 166
void
afterDelete(callable $callback)
<p>Register a callback to be run once after the model is deleted.</p>
in AbstractModel
at
line 174
array
releaseAfterSaveCallbacks()
in AbstractModel
at
line 186
array
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 195
__call($method, $parameters)
in AbstractModel
at
line 204
newModelQuery()
in AbstractModel
at
line 215
qualifyColumn($column)
in AbstractModel
at
line 224
mixed
withTableAlias(callable $callback)
in AbstractModel
at
line 236
Collection
newCollection(array $models = [])
in AbstractModel
at
line 241
__sleep()
in EventGeneratorTrait
at
line 16
void
raise(object $event)
in EventGeneratorTrait
at
line 24
array
releaseEvents()
<p>Return and reset all pending events.</p>
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')
<p>Scope a query to only include records that are visible to a user.</p>
in ScopeVisibilityTrait
at
line 19
static Builder
whereVisibleTo(User $user)
at
line 176
static void
setDisplayNameDriver(DriverInterface $driver)
at
line 181
static void
setPasswordCheckers(array $checkers)
at
line 230
void
setPasswordAttribute(string|null $value)
<p>Set the password attribute, storing it as a hash.</p>
at
line 264
string|null
getAvatarUrlAttribute(string|null $value = null)
at
line 273
string
getDisplayNameAttribute()
at
line 278
bool
checkPassword(string $password)
at
line 306
bool
hasPermission(string $permission)
at
line 319
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 338
array
getAlertableNotificationTypes()
<p>Get the notification types that should be alerted to this user, according to their preferences.</p>
at
line 345
int
getUnreadNotificationCount()
at
line 353
protected HasMany
unreadNotifications()
at
line 365
protected Collection
getUnreadNotifications()
at
line 373
int
getNewNotificationCount()
<p>Get the number of new, unseen notifications for the user.</p>
at
line 384
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 398
void
setPreferencesAttribute(array $value)
<p>Encode an array of preferences for storage in the database.</p>
at
line 407
bool
shouldAlert(string $type)
<p>Check whether the user should receive an alert for a notification type.</p>
at
line 416
bool
shouldEmail(string $type)
<p>Check whether the user should receive an email for a notification type.</p>
at
line 421
mixed
getPreference(string $key, mixed $default = null)
at
line 454
bool
isAdmin()
at
line 462
bool
isGuest()
<p>Check whether the user is a guest.</p>
at
line 477
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>
at
line 493
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>
at
line 503
void
assertCan(string $ability, mixed $arguments = null)
at
line 513
void
assertAdmin()
at
line 521
HasMany
posts()
at
line 529
HasMany
discussions()
at
line 537
BelongsToMany
read()
at
line 545
BelongsToMany
groups()
at
line 550
BelongsToMany
visibleGroups()
at
line 558
HasMany
notifications()
at
line 566
HasMany
emailTokens()
at
line 574
HasMany
passwordTokens()
at
line 585
Builder
permissions()
<p>Define the relationship with the permissions of all the groups that the user is in.</p>
at
line 609
array
getPermissions()
<p>Get a list of permissions that the user has.</p>
at
line 621
HasMany
accessTokens()
at
line 629
HasMany
loginProviders()
at
line 634
bool
can(string $ability, mixed $arguments = null)
at
line 639
bool
cannot(string $ability, mixed $arguments = null)
at
line 649
static void
setHasher(Hasher $hasher)
<p>Set the hasher with which to hash passwords.</p>
at
line 659
static void
registerPreference(string $key, callable $transformer = null, mixed $default = null)
<p>Register a preference with a transformer and a default value.</p>
at
line 669
static void
addGroupProcessor(callable $callback)
<p>Register a callback that processes a user's list of groups.</p>
at
line 678
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>