class User extends AbstractModel
Traits
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 |
|
protected array | $pendingEvents | from EventGeneratorTrait |
|
|
protected | $table | {@inheritdoc} |
|
|
protected | $dates | {@inheritdoc} |
|
|
protected string[]|null | $permissions | An array of permissions that this user has. |
|
|
protected SessionInterface | $session |
|
||
array | $preferences |
|
||
static protected Hasher | $hasher | The hasher with which to hash passwords. |
|
|
static protected Gate | $gate | The access gate. |
|
|
int | $id |
|
||
string | $username |
|
||
string |
|
|||
bool | $is_activated |
|
||
string | $password |
|
||
string | $locale |
|
||
string | $bio |
|
||
string|null | $avatar_path |
|
||
string | $avatar_url |
|
||
Carbon|null | $join_time |
|
||
Carbon|null | $last_seen_time |
|
||
Carbon|null | $read_time |
|
||
Carbon|null | $notifications_read_time |
|
||
int | $discussions_count |
|
||
int | $comments_count |
|
Methods
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
Scope a query to only include records that are visible to a user.
Get the user's locale, falling back to the forum's default if they haven't set one.
Check whether the user has a certain permission based on their groups.
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.
Check whether or not the user should receive an alert for a notification type.
Check whether or not the user should receive an email for a notification type.
Get the value of a preference for this user.
Define the relationship with the permissions of all of the groups that the user is in.
Register a preference with a transformer and a default value.
Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.
Details
at
line 116
static
boot()
Boot the model.
in AbstractModel
at
line 74
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 92
array
getDates()
Get the attributes that should be converted to dates.
in AbstractModel
at
line 116
mixed
getAttribute(string $key)
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
in AbstractModel
at
line 142
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 155
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 166
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 174
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 186
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 198
__call($method, $arguments)
{@inheritdoc}
in EventGeneratorTrait
at
line 26
raise(mixed $event)
Raise a new event.
in EventGeneratorTrait
at
line 36
array
releaseEvents()
Return and reset all pending events.
in ScopeVisibilityTrait
at
line 26
scopeWhereVisibleTo(Builder $query, User $actor)
Scope a query to only include records that are visible to a user.
at
line 160
static User
register(string $username, string $email, string $password)
Register a new user.
at
line 177
static Gate
getGate()
at
line 185
static
setGate(Gate $gate)
at
line 196
$this
rename(string $username)
Rename the user.
at
line 213
$this
changeEmail(string $email)
Change the user's email.
at
line 230
$this
requestEmailChange(string $email)
Request that the user's email be changed.
at
line 245
$this
changePassword(string $password)
Change the user's password.
at
line 259
setPasswordAttribute(string $value)
Set the password attribute, storing it as a hash.
at
line 270
$this
changeBio(string $bio)
Change the user's bio.
at
line 284
$this
markAllAsRead()
Mark all discussions as read.
at
line 296
$this
markNotificationsAsRead()
Mark all notifications as read.
at
line 309
$this
changeAvatarPath(string $path)
Change the path of the user avatar.
at
line 324
string
getAvatarUrlAttribute()
Get the URL of the user's avatar.
at
line 338
string
getLocaleAttribute(string $value)
Get the user's locale, falling back to the forum's default if they haven't set one.
at
line 349
bool
checkPassword(string $password)
Check if a given password matches the user's password.
at
line 365
$this
activate()
Activate the user's account.
at
line 382
bool
hasPermission(string $permission)
Check whether the user has a certain permission based on their groups.
at
line 402
bool
hasPermissionLike(string $match)
Check whether the user has a permission that is like the given string, based on their groups.
at
line 427
array
getAlertableNotificationTypes()
Get the notification types that should be alerted to this user, according to their preferences.
at
line 439
int
getUnreadNotificationsCount()
Get the number of unread notifications for the user.
at
line 449
protected Collection
getUnreadNotifications()
Get all notifications that have not been read yet.
at
line 469
int
getNewNotificationsCount()
Get the number of new, unseen notifications for the user.
at
line 483
array
getPreferencesAttribute(string $value)
Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.
at
line 499
setPreferencesAttribute(mixed $value)
Encode an array of preferences for storage in the database.
at
line 511
bool
shouldAlert(string $type)
Check whether or not the user should receive an alert for a notification type.
at
line 523
bool
shouldEmail(string $type)
Check whether or not the user should receive an email for a notification type.
at
line 535
mixed
getPreference(string $key, mixed $default = null)
Get the value of a preference for this user.
at
line 547
$this
setPreference(string $key, mixed $value)
Set the value of a preference for this user.
at
line 569
$this
updateLastSeen()
Set the user as being last seen just now.
at
line 581
bool
isAdmin()
Check whether or not the user is an administrator.
at
line 591
bool
isGuest()
Check whether or not the user is a guest.
at
line 601
HasMany
posts()
Define the relationship with the user's posts.
at
line 611
BelongsTo
read()
Define the relationship with the user's read discussions.
at
line 621
BelongsToMany
groups()
Define the relationship with the user's groups.
at
line 631
HasMany
notifications()
Define the relationship with the user's notifications.
at
line 642
Builder
permissions()
Define the relationship with the permissions of all of the groups that the user is in.
at
line 664
string[]
getPermissions()
Get a list of permissions that the user has.
at
line 674
HasMany
accessTokens()
Define the relationship with the user's access tokens.
at
line 684
bool
can(string $ability, array|mixed $arguments = [])
at
line 694
bool
cannot(string $ability, array|mixed $arguments = [])
at
line 702
SessionInterface
getSession()
at
line 710
setSession(SessionInterface $session)
at
line 720
static
setHasher(Hasher $hasher)
Set the hasher with which to hash passwords.
at
line 732
static
addPreference(string $key, callable $transformer = null, mixed $default = null)
Register a preference with a transformer and a default value.
at
line 745
static string
getNotificationPreferenceKey(string $type, string $method)
Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.