class Guest extends User
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 | $customRelations | from AbstractModel |
|
|
| static | $dateAttributes | from AbstractModel |
|
|
| static | $defaults | from AbstractModel |
|
|
| protected array | $pendingEvents | from EventGeneratorTrait |
|
|
| static protected | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected array | $dates | The attributes that should be mutated to dates. | from User |
|
| protected string[]|null | $permissions | An array of permissions that this user has. | from User |
|
| static protected | $groupProcessors | An array of callables, through each of which the user's list of groups is passed before being returned. | from User |
|
| array | $preferences | from User |
|
|
| static protected DriverInterface | $displayNameDriver | A driver for getting display names. | from User |
|
| static protected Hasher | $hasher | The hasher with which to hash passwords. | from User |
|
| static protected Gate | $gate | The access gate. | from User |
|
| static protected array | $passwordCheckers | Callbacks to check passwords. | from User |
|
| int | $id | Override the ID of this user, as a guest does not have an ID. |
|
|
| string | $username | from User |
|
|
| string | $display_name | from User |
|
|
| string | from User |
|
||
| bool | $is_email_confirmed | from User |
|
|
| string | $password | from User |
|
|
| string|null | $avatar_url | from User |
|
|
| Carbon|null | $joined_at | from User |
|
|
| Carbon|null | $last_seen_at | from User |
|
|
| Carbon|null | $marked_all_as_read_at | from User |
|
|
| Carbon|null | $read_notifications_at | from User |
|
|
| int | $discussion_count | from User |
|
|
| int | $comment_count | from User |
|
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.
Register a new user.
Check if a given password matches the user's password.
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.
Encode an array of preferences for storage in the database.
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.
Set 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.
Register a callback that processes a user's list of groups.
Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.
Details
in AbstractModel
at
line 85
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 105
array
getDates()
Get the attributes that should be converted to dates.
in AbstractModel
at
line 123
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 149
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 165
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 176
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 184
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 196
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 208
__call($method, $arguments)
{@inheritdoc}
in EventGeneratorTrait
at
line 24
raise(mixed $event)
Raise a new event.
in EventGeneratorTrait
at
line 34
array
releaseEvents()
Return and reset all pending events.
in ScopeVisibilityTrait
at
line 20
static
registerVisibilityScoper($scoper, $ability = null)
in ScopeVisibilityTrait
at
line 41
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
Scope a query to only include records that are visible to a user.
static User
register(string $username, string $email, string $password)
Register a new user.
static
setDisplayNameDriver(DriverInterface $driver)
Set the display name driver.
$this
requestEmailChange(string $email)
Request that the user's email be changed.
setPasswordAttribute(string $value)
Set the password attribute, storing it as a hash.
string
getAvatarUrlAttribute(string $value = null)
Get the URL of the user's avatar.
bool
checkPassword(string $password)
Check if a given password matches the user's password.
bool
hasPermission(string $permission)
Check whether the user has a certain permission based on their groups.
bool
hasPermissionLike(string $match)
Check whether the user has a permission that is like the given string, based on their groups.
array
getAlertableNotificationTypes()
Get the notification types that should be alerted to this user, according to their preferences.
int
getUnreadNotificationCount()
Get the number of unread notifications for the user.
protected Collection
getUnreadNotifications()
Get all notifications that have not been read yet.
int
getNewNotificationCount()
Get the number of new, unseen notifications for the user.
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.
setPreferencesAttribute(mixed $value)
Encode an array of preferences for storage in the database.
bool
shouldAlert(string $type)
Check whether or not the user should receive an alert for a notification type.
bool
shouldEmail(string $type)
Check whether or not the user should receive an email for a notification type.
mixed
getPreference(string $key, mixed $default = null)
Get the value of a preference for this user.
$this
setPreference(string $key, mixed $value)
Set the value of a preference for this user.
at
line 40
bool
isGuest()
Check whether or not the user is a guest.
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.
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).
Builder
permissions()
Define the relationship with the permissions of all of the groups that the user is in.
static
registerPreference(string $key, callable $transformer = null, mixed $default = null)
Register a preference with a transformer and a default value.
static array
addGroupProcessor(callable $callback)
Register a callback that processes a user's list of groups.
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.