PHP Class Flarum\Core\User

Inheritance: extends Flarum\Database\AbstractModel, use trait Flarum\Core\Support\EventGeneratorTrait, use trait Flarum\Core\Support\ScopeVisibilityTrait
Afficher le fichier Open project: flarum/core Class Usage Examples

Protected Properties

Свойство Type Description
$dates
$gate Flarum\Core\Access\Gate The access gate.
$hasher Illuminate\Contracts\Hashing\Hasher The hasher with which to hash passwords.
$permissions string[] | null An array of permissions that this user has.
$preferences array - transformer: a callback that confines the value of the preference - default: a default value if the preference isn't set
$session Symfony\Component\HttpFoundation\Session\SessionInterface
$table

Méthodes publiques

Méthode Description
accessTokens ( ) : Illuminate\Database\Eloquent\Relations\HasMany Define the relationship with the user's access tokens.
activate ( ) Activate the user's account.
addPreference ( string $key, callable $transformer = null, mixed $default = null ) Register a preference with a transformer and a default value.
boot ( ) : void Boot the model.
can ( string $ability, array | mixed $arguments = [] ) : boolean
cannot ( string $ability, array | mixed $arguments = [] ) : boolean
changeAvatarPath ( string $path ) Change the path of the user avatar.
changeBio ( string $bio ) Change the user's bio.
changeEmail ( string $email ) Change the user's email.
changePassword ( string $password ) Change the user's password.
checkPassword ( string $password ) : boolean Check if a given password matches the user's password.
getAlertableNotificationTypes ( ) : array Get the notification types that should be alerted to this user, according to their preferences.
getAvatarUrlAttribute ( ) : string Get the URL of the user's avatar.
getGate ( ) : Flarum\Core\Access\Gate
getLocaleAttribute ( string $value ) : string Get the user's locale, falling back to the forum's default if they haven't set one.
getNewNotificationsCount ( ) : integer Get the number of new, unseen notifications for the user.
getNotificationPreferenceKey ( string $type, string $method ) : string Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.
getPermissions ( ) : string[] Get a list of permissions that the user has.
getPreference ( string $key, mixed $default = null ) : mixed Get the value of a preference for this user.
getPreferencesAttribute ( string $value ) : array Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.
getSession ( ) : Symfony\Component\HttpFoundation\Session\SessionInterface
getUnreadNotificationsCount ( ) : integer Get the number of unread notifications for the user.
groups ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany Define the relationship with the user's groups.
hasPermission ( string $permission ) : boolean Check whether the user has a certain permission based on their groups.
hasPermissionLike ( string $match ) : boolean Check whether the user has a permission that is like the given string, based on their groups.
isAdmin ( ) : boolean Check whether or not the user is an administrator.
isGuest ( ) : boolean Check whether or not the user is a guest.
markAllAsRead ( ) Mark all discussions as read.
markNotificationsAsRead ( ) Mark all notifications as read.
notifications ( ) : Illuminate\Database\Eloquent\Relations\HasMany Define the relationship with the user's notifications.
permissions ( ) : Builder Define the relationship with the permissions of all of the groups that the user is in.
posts ( ) : Illuminate\Database\Eloquent\Relations\HasMany Define the relationship with the user's posts.
read ( ) : BelongsTo Define the relationship with the user's read discussions.
register ( string $username, string $email, string $password ) : static Register a new user.
rename ( string $username ) Rename the user.
requestEmailChange ( string $email ) Request that the user's email be changed.
setGate ( Flarum\Core\Access\Gate $gate )
setHasher ( Illuminate\Contracts\Hashing\Hasher $hasher ) Set the hasher with which to hash passwords.
setPasswordAttribute ( string $value ) Set the password attribute, storing it as a hash.
setPreference ( string $key, mixed $value ) Set the value of a preference for this user.
setPreferencesAttribute ( mixed $value ) Encode an array of preferences for storage in the database.
setSession ( Symfony\Component\HttpFoundation\Session\SessionInterface $session )
shouldAlert ( string $type ) : boolean Check whether or not the user should receive an alert for a notification type.
shouldEmail ( string $type ) : boolean Check whether or not the user should receive an email for a notification type.
updateLastSeen ( ) Set the user as being last seen just now.

Méthodes protégées

Méthode Description
getUnreadNotifications ( ) : Illuminate\Database\Eloquent\Collection Get all notifications that have not been read yet.

Method Details

accessTokens() public méthode

Define the relationship with the user's access tokens.
public accessTokens ( ) : Illuminate\Database\Eloquent\Relations\HasMany
Résultat Illuminate\Database\Eloquent\Relations\HasMany

activate() public méthode

Activate the user's account.
public activate ( )

addPreference() public static méthode

Register a preference with a transformer and a default value.
public static addPreference ( string $key, callable $transformer = null, mixed $default = null )
$key string
$transformer callable
$default mixed

boot() public static méthode

Boot the model.
public static boot ( ) : void
Résultat void

can() public méthode

public can ( string $ability, array | mixed $arguments = [] ) : boolean
$ability string
$arguments array | mixed
Résultat boolean

cannot() public méthode

public cannot ( string $ability, array | mixed $arguments = [] ) : boolean
$ability string
$arguments array | mixed
Résultat boolean

changeAvatarPath() public méthode

Change the path of the user avatar.
public changeAvatarPath ( string $path )
$path string

changeBio() public méthode

Change the user's bio.
public changeBio ( string $bio )
$bio string

changeEmail() public méthode

Change the user's email.
public changeEmail ( string $email )
$email string

changePassword() public méthode

Change the user's password.
public changePassword ( string $password )
$password string

checkPassword() public méthode

Check if a given password matches the user's password.
public checkPassword ( string $password ) : boolean
$password string
Résultat boolean

getAlertableNotificationTypes() public méthode

Get the notification types that should be alerted to this user, according to their preferences.
public getAlertableNotificationTypes ( ) : array
Résultat array

getAvatarUrlAttribute() public méthode

Get the URL of the user's avatar.
public getAvatarUrlAttribute ( ) : string
Résultat string

getGate() public static méthode

public static getGate ( ) : Flarum\Core\Access\Gate
Résultat Flarum\Core\Access\Gate

getLocaleAttribute() public méthode

Get the user's locale, falling back to the forum's default if they haven't set one.
public getLocaleAttribute ( string $value ) : string
$value string
Résultat string

getNewNotificationsCount() public méthode

Get the number of new, unseen notifications for the user.
public getNewNotificationsCount ( ) : integer
Résultat integer

getNotificationPreferenceKey() public static méthode

Get the key for a preference which flags whether or not the user will receive a notification for $type via $method.
public static getNotificationPreferenceKey ( string $type, string $method ) : string
$type string
$method string
Résultat string

getPermissions() public méthode

Get a list of permissions that the user has.
public getPermissions ( ) : string[]
Résultat string[]

getPreference() public méthode

Get the value of a preference for this user.
public getPreference ( string $key, mixed $default = null ) : mixed
$key string
$default mixed
Résultat mixed

getPreferencesAttribute() public méthode

Get the values of all registered preferences for this user, by transforming their stored preferences and merging them with the defaults.
public getPreferencesAttribute ( string $value ) : array
$value string
Résultat array

getSession() public méthode

public getSession ( ) : Symfony\Component\HttpFoundation\Session\SessionInterface
Résultat Symfony\Component\HttpFoundation\Session\SessionInterface

getUnreadNotifications() protected méthode

Get all notifications that have not been read yet.
protected getUnreadNotifications ( ) : Illuminate\Database\Eloquent\Collection
Résultat Illuminate\Database\Eloquent\Collection

getUnreadNotificationsCount() public méthode

Get the number of unread notifications for the user.

groups() public méthode

Define the relationship with the user's groups.
public groups ( ) : Illuminate\Database\Eloquent\Relations\BelongsToMany
Résultat Illuminate\Database\Eloquent\Relations\BelongsToMany

hasPermission() public méthode

Check whether the user has a certain permission based on their groups.
public hasPermission ( string $permission ) : boolean
$permission string
Résultat boolean

hasPermissionLike() public méthode

Check whether the user has a permission that is like the given string, based on their groups.
public hasPermissionLike ( string $match ) : boolean
$match string
Résultat boolean

isAdmin() public méthode

Check whether or not the user is an administrator.
public isAdmin ( ) : boolean
Résultat boolean

isGuest() public méthode

Check whether or not the user is a guest.
public isGuest ( ) : boolean
Résultat boolean

markAllAsRead() public méthode

Mark all discussions as read.
public markAllAsRead ( )

markNotificationsAsRead() public méthode

Mark all notifications as read.

notifications() public méthode

Define the relationship with the user's notifications.
public notifications ( ) : Illuminate\Database\Eloquent\Relations\HasMany
Résultat Illuminate\Database\Eloquent\Relations\HasMany

permissions() public méthode

Define the relationship with the permissions of all of the groups that the user is in.
public permissions ( ) : Builder
Résultat Illuminate\Database\Eloquent\Builder

posts() public méthode

Define the relationship with the user's posts.
public posts ( ) : Illuminate\Database\Eloquent\Relations\HasMany
Résultat Illuminate\Database\Eloquent\Relations\HasMany

read() public méthode

Define the relationship with the user's read discussions.
public read ( ) : BelongsTo
Résultat Illuminate\Database\Eloquent\Relations\BelongsTo

register() public static méthode

Register a new user.
public static register ( string $username, string $email, string $password ) : static
$username string
$email string
$password string
Résultat static

rename() public méthode

Rename the user.
public rename ( string $username )
$username string

requestEmailChange() public méthode

Request that the user's email be changed.
public requestEmailChange ( string $email )
$email string

setGate() public static méthode

public static setGate ( Flarum\Core\Access\Gate $gate )
$gate Flarum\Core\Access\Gate

setHasher() public static méthode

Set the hasher with which to hash passwords.
public static setHasher ( Illuminate\Contracts\Hashing\Hasher $hasher )
$hasher Illuminate\Contracts\Hashing\Hasher

setPasswordAttribute() public méthode

Set the password attribute, storing it as a hash.
public setPasswordAttribute ( string $value )
$value string

setPreference() public méthode

Set the value of a preference for this user.
public setPreference ( string $key, mixed $value )
$key string
$value mixed

setPreferencesAttribute() public méthode

Encode an array of preferences for storage in the database.
public setPreferencesAttribute ( mixed $value )
$value mixed

setSession() public méthode

public setSession ( Symfony\Component\HttpFoundation\Session\SessionInterface $session )
$session Symfony\Component\HttpFoundation\Session\SessionInterface

shouldAlert() public méthode

Check whether or not the user should receive an alert for a notification type.
public shouldAlert ( string $type ) : boolean
$type string
Résultat boolean

shouldEmail() public méthode

Check whether or not the user should receive an email for a notification type.
public shouldEmail ( string $type ) : boolean
$type string
Résultat boolean

updateLastSeen() public méthode

Set the user as being last seen just now.
public updateLastSeen ( )

Property Details

$dates protected_oe property

protected $dates

$gate protected_oe static_oe property

The access gate.
protected static Gate,Flarum\Core\Access $gate
Résultat Flarum\Core\Access\Gate

$hasher protected_oe static_oe property

The hasher with which to hash passwords.
protected static Hasher,Illuminate\Contracts\Hashing $hasher
Résultat Illuminate\Contracts\Hashing\Hasher

$permissions protected_oe property

An array of permissions that this user has.
protected string[]|null $permissions
Résultat string[] | null

$preferences protected_oe static_oe property

- transformer: a callback that confines the value of the preference - default: a default value if the preference isn't set
protected static array $preferences
Résultat array

$session protected_oe property

protected SessionInterface,Symfony\Component\HttpFoundation\Session $session
Résultat Symfony\Component\HttpFoundation\Session\SessionInterface

$table protected_oe property

protected $table