trait Followable (View source)

Methods to make a model "followable" per user.

A followable model can be "followed" or "ignored" by each user, which will determine how they see and are notified about activity in the model. The model must have user state (see HasUserState) with notification and followed_at columns to store this state.

Properties

Collection read-only $followedBy
Collection read-only $ignoredBy

Methods

BelongsToMany
followedBy()

Relationship with all users who are following this model.

BelongsToMany
ignoredBy()

Relationship with all users who are ignoring this model.

void
scopeFollowing(Builder $query)

Find only models that the current user is following.

void
scopeIgnoring(Builder $query)

Find only models that the current user is ignoring.

void
setNotifications(string|null $value)

Save the current user's notification preference for this model.

void
follow()

Follow this model for the current user.

void
unfollow()

Unfollow this model for the current user.

void
ignore()

Ignore this model for the current user.

void
unignore()

Unignore this model for the current user.

bool
isFollowed()

Whether the current user is following this model.

bool
isIgnored()

Whether the current user is ignoring this model.

Details

BelongsToMany followedBy()

Relationship with all users who are following this model.

Return Value

BelongsToMany

BelongsToMany ignoredBy()

Relationship with all users who are ignoring this model.

Return Value

BelongsToMany

void scopeFollowing(Builder $query)

Find only models that the current user is following.

Parameters

Builder $query

Return Value

void

void scopeIgnoring(Builder $query)

Find only models that the current user is ignoring.

Parameters

Builder $query

Return Value

void

protected void setNotifications(string|null $value)

Save the current user's notification preference for this model.

Parameters

string|null $value

Return Value

void

void follow()

Follow this model for the current user.

Return Value

void

void unfollow()

Unfollow this model for the current user.

Return Value

void

void ignore()

Ignore this model for the current user.

Return Value

void

void unignore()

Unignore this model for the current user.

Return Value

void

bool isFollowed()

Whether the current user is following this model.

Return Value

bool

bool isIgnored()

Whether the current user is ignoring this model.

Return Value

bool