PHP Class Flarum\Core\Notification

A notification record is associated with a user, and shows up in their notification list. A notification indicates that something has happened that the user should know about, like if a user's discussion was renamed by someone else. Each notification record has a *type*. The type determines how the record looks in the notifications list, and what *subject* is associated with it. For example, the 'discussionRenamed' notification type represents that someone renamed a user's discussion. Its subject is a discussion, of which the ID is stored in the subject_id column.
Inheritance: extends Flarum\Database\AbstractModel
Afficher le fichier Open project: flarum/core Class Usage Examples

Protected Properties

Свойство Type Description
$dates
$subjectModels array A map of notification types and the model classes to use for their subjects. For example, the 'discussionRenamed' notification type, which represents that a user's discussion was renamed, has the subject model class 'Flarum\Core\Discussion'.
$table

Méthodes publiques

Méthode Description
getDataAttribute ( string $value ) : mixed When getting the data attribute, unserialize the JSON stored in the database into a plain array.
getSubjectModelAttribute ( ) : string | null Get the subject model for this notification record by looking up its type in our subject model map.
getSubjectModels ( ) : array Get the type-to-subject-model map.
read ( ) : void Mark a notification as read.
sender ( ) : BelongsTo Define the relationship with the notification's sender.
setDataAttribute ( mixed $value ) When setting the data attribute, serialize it into JSON for storage in the database.
setSubjectModel ( string $type, string $subjectModel ) : void Set the subject model for the given notification type.
subject ( ) : Illuminate\Database\Eloquent\Relations\MorphTo Define the relationship with the notification's subject.
user ( ) : BelongsTo Define the relationship with the notification's recipient.

Method Details

getDataAttribute() public méthode

When getting the data attribute, unserialize the JSON stored in the database into a plain array.
public getDataAttribute ( string $value ) : mixed
$value string
Résultat mixed

getSubjectModelAttribute() public méthode

Get the subject model for this notification record by looking up its type in our subject model map.
public getSubjectModelAttribute ( ) : string | null
Résultat string | null

getSubjectModels() public static méthode

Get the type-to-subject-model map.
public static getSubjectModels ( ) : array
Résultat array

read() public méthode

Mark a notification as read.
public read ( ) : void
Résultat void

sender() public méthode

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

setDataAttribute() public méthode

When setting the data attribute, serialize it into JSON for storage in the database.
public setDataAttribute ( mixed $value )
$value mixed

setSubjectModel() public static méthode

Set the subject model for the given notification type.
public static setSubjectModel ( string $type, string $subjectModel ) : void
$type string The notification type.
$subjectModel string The class name of the subject model for that type.
Résultat void

subject() public méthode

Define the relationship with the notification's subject.
public subject ( ) : Illuminate\Database\Eloquent\Relations\MorphTo
Résultat Illuminate\Database\Eloquent\Relations\MorphTo

user() public méthode

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

Property Details

$dates protected_oe property

protected $dates

$subjectModels protected_oe static_oe property

A map of notification types and the model classes to use for their subjects. For example, the 'discussionRenamed' notification type, which represents that a user's discussion was renamed, has the subject model class 'Flarum\Core\Discussion'.
protected static array $subjectModels
Résultat array

$table protected_oe property

protected $table