class Notification extends AbstractModel

Models a notification record in the database.

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.

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 $casts
static protected AbstractModel>> $subjectModels <p>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\Discussion\Discussion'.</p>
int $id
int $user_id
int|null $from_user_id
string $type
int|null $subject_id
array|null $data
Carbon $created_at
Carbon $read_at
Carbon $deleted_at
User|null $user
User|null $fromUser
AbstractModel|Post|Discussion|null $subject

Methods

static 
boot()

No description

__construct(array $attributes = [])

No description

array
getCasts()

No description

getAttribute($key)

<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>

mixed
getCustomRelation(string $name)

<p>Get a custom relation object.</p>

void
afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

void
afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

array
releaseAfterSaveCallbacks()

No description

array
releaseAfterDeleteCallbacks()

No description

__call($method, $parameters)

No description

newModelQuery()

No description

qualifyColumn($column)

No description

mixed
withTableAlias(callable $callback)

No description

newCollection(array $models = [])

No description

__sleep()

No description

void
read()

No description

string|null
getSubjectModelAttribute()

<p>Get the subject model for this notification record by looking up its type in our subject model map.</p>

BelongsTo
user()

No description

BelongsTo
fromUser()

No description

MorphTo
subject()

No description

Builder
scopeWhereSubjectVisibleTo(Builder $query, User $actor)

<p>Scope the query to include only notifications whose subjects are visible to the given user.</p>

Builder
scopeWhereSubject(Builder $query, AbstractModel $model)

<p>Scope the query to include only notifications that have the given subject.</p>

Builder
scopeWhereSubjectModel(Builder $query, string $class)

<p>Scope the query to include only notification types that use the given subject model.</p>

Builder
scopeMatchingBlueprint(Builder $query, BlueprintInterface $blueprint)

<p>Scope the query to find all records matching the given blueprint.</p>

static void
notify(array $recipients, BlueprintInterface $blueprint)

<p>Send notifications to the given recipients.</p>

static array
getSubjectModels()

<p>Get the type-to-subject-model map.</p>

static void
setSubjectModel(string $type, string $subjectModel)

<p>Set the subject model for the given notification type.</p>

static array
getBlueprintAttributes(BlueprintInterface $blueprint)

No description

void
static() $Illuminate\Database\Eloquent\Builder matchingBlueprint(BlueprintInterface $blueprint)

No description

Details

static boot()

__construct(array $attributes = [])

Parameters

array $attributes

array getCasts()

Return Value

array

getAttribute($key)

<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>

Parameters

$key

protected mixed getCustomRelation(string $name)

<p>Get a custom relation object.</p>

Parameters

string $name

Return Value

mixed

void afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

Parameters

callable $callback

Return Value

void

void afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

Parameters

callable $callback

Return Value

void

array releaseAfterSaveCallbacks()

Return Value

array

array releaseAfterDeleteCallbacks()

Return Value

array

__call($method, $parameters)

Parameters

$method
$parameters

newModelQuery()

qualifyColumn($column)

Parameters

$column

mixed withTableAlias(callable $callback)

Parameters

callable $callback

Return Value

mixed

Collection newCollection(array $models = [])

Parameters

array $models

Return Value

Collection

__sleep()

void read()

Return Value

void

string|null getSubjectModelAttribute()

<p>Get the subject model for this notification record by looking up its type in our subject model map.</p>

Return Value

string|null

BelongsTo user()

Return Value

BelongsTo

BelongsTo fromUser()

Return Value

BelongsTo

MorphTo subject()

Return Value

MorphTo

Builder scopeWhereSubjectVisibleTo(Builder $query, User $actor)

<p>Scope the query to include only notifications whose subjects are visible to the given user.</p>

Parameters

Builder $query
User $actor

Return Value

Builder

Builder scopeWhereSubject(Builder $query, AbstractModel $model)

<p>Scope the query to include only notifications that have the given subject.</p>

Parameters

Builder $query
AbstractModel $model

Return Value

Builder

Builder scopeWhereSubjectModel(Builder $query, string $class)

<p>Scope the query to include only notification types that use the given subject model.</p>

Parameters

Builder $query
string $class

Return Value

Builder

Builder scopeMatchingBlueprint(Builder $query, BlueprintInterface $blueprint)

<p>Scope the query to find all records matching the given blueprint.</p>

Parameters

Builder $query
BlueprintInterface $blueprint

Return Value

Builder

static void notify(array $recipients, BlueprintInterface $blueprint)

<p>Send notifications to the given recipients.</p>

Parameters

array $recipients
BlueprintInterface $blueprint

Return Value

void

static array getSubjectModels()

<p>Get the type-to-subject-model map.</p>

Return Value

array

static void setSubjectModel(string $type, string $subjectModel)

<p>Set the subject model for the given notification type.</p>

Parameters

string $type <p>The notification type.</p>
string $subjectModel <p>The class name of the subject model for that type.</p>

Return Value

void

static protected array getBlueprintAttributes(BlueprintInterface $blueprint)

Parameters

BlueprintInterface $blueprint

Return Value

array

void static() $Illuminate\Database\Eloquent\Builder matchingBlueprint(BlueprintInterface $blueprint)

Parameters

) $Illuminate\Database\Eloquent\Builder matchingBlueprint(BlueprintInterface $blueprint

Return Value

void