Post
class Post extends Model (View source)
Traits
Methods to make a model "followable" per user.
Methods to give a model a formatted text body
.
Methods to manage reactions on a model.
Methods to give a model per-user state.
Trait for models that notifications can be about.
Constants
UPDATED_AT |
|
Properties
static protected | $unguarded | from Model | |
Collection read-only | $followedBy | from Followable | |
Collection read-only | $ignoredBy | from Followable | |
static protected Formatter[] | $formatters | from UsesFormatter | |
string | $body | The original unformatted version of the body. |
from HasBody |
string | $parsed_body | The intermediary parsed XML document. |
from HasBody |
HtmlString read-only | $body_html | The formatted HTML version of the body for the current user. |
from HasBody |
string read-only | $body_text | The parsed body with formatting removed. |
from HasBody |
Collection read-only | $mentions | from HasBody | |
Collection read-only | $attachments | from HasBody | |
protected | $casts | ||
int | $id | ||
int | $channel_id | ||
null|int | $user_id | ||
null|string | $title | ||
null|string | $slug | ||
null|Carbon | $created_at | ||
null|Carbon | $edited_at | ||
null|Carbon | $deleted_at | ||
null|Carbon | $last_activity_at | ||
int | $comment_count | ||
int | $score | ||
bool | $is_locked | ||
null|int | $answer_id | ||
bool | $is_pinned | ||
Channel read-only | $channel | ||
null|User read-only | $user | ||
Collection read-only | $comments | ||
Collection read-only | $unreadComments | ||
Collection read-only | $tags | ||
null|Comment read-only | $lastComment | ||
null|PostUser read-only | $userState | ||
null|Comment read-only | $answer | ||
string read-only | $url | ||
string read-only | $edit_url | ||
string read-only | $unread_url | ||
null|int read-only | $unread_comments_count |
Methods
Relationship with all users who are following this model.
Find only models that the current user is following.
Find only models that the current user is ignoring.
Save the current user's notification preference for this model.
Set a formatter instance for this model.
Relationship with the uploads that were attached in the body.
Relationship with a summary of the reactions for this model.
No description
Relationship with the notifications about this model.
Relationship with the notifications grouped by this model.
No description
Update the user state for any users mentioned in this post.
Query posts that are unread for the current user.
Scope to select count of comments that are unread.
Relationship with the post's channel.
Relationship with the post's author.
Relationship with the post's comments.
Relationship with the post's most recent comment.
Relationship with the post's answer comment.
Relationship with the post's tags.
Generate a URL for a particular comment index in this post.
Mark this post as having been edited just now.
Refresh the metadata about this post's comments.
Determine whether this post contains any new activity for the current user.
Determine whether this post has been fully read by the current user.
Determine whether this post has never before been seen by the current user.
Get the Turbo Streams that should be sent when this post is updated.
Get the Turbo Streams that should be sent when this post is removed.
No description
No description
No description
No description
No description
No description
Details
in
Model at line 18
getConnectionName()
No description
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.
protected 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.
HtmlString|string
format(string $attribute, User $user = null)
Render an attribute as HTML for the given user.
static Formatter
getFormatter(string $attribute)
Set a formatter instance for this model.
static void
setFormatter(string $attribute, Formatter $formatter)
Set a formatter instance for this model.
getAttribute($key)
No description
setAttribute($key, $value)
No description
static void
bootHasBody()
No description
MorphToMany
mentions()
Relationship with the users who were mentioned in the body.
MorphToMany
attachments()
Relationship with the uploads that were attached in the body.
MorphMany
reactions()
Relationship with the reactions for this model.
ReactionsSummaryRelation
reactionsSummary()
Relationship with a summary of the reactions for this model.
This is less expensive to load than all of the actual reactions.
ReactionSet|null
reactionSet()
No description
Reactable
recalculateScore()
Recalculate the score from the reactions.
HasOne
userState(User $user = null)
Relationship with the state record for a user.
Defaults to the current user when no user is specified, as is the case when eager-loading the relationship.
The model representing the user state table is derived by appending
User
to the parent model name (eg. PostUser
). Alternatively, it can
be specified by setting the userStateModel
property.
HasUserState
loadUserState(User $user)
Load the userState relationship for the given user.
static void
bootNotificationContent()
No description
MorphMany
notifications()
Relationship with the notifications about this model.
MorphMany
groupedNotifications()
Relationship with the notifications grouped by this model.
static
booting()
No description
void
usersWereMentioned(Collection $users)
Update the user state for any users mentioned in this post.
scopeUnread(Builder $query)
Query posts that are unread for the current user.
void
scopeWithUnreadCommentsCount(Builder $query)
Scope to select count of comments that are unread.
BelongsTo
channel()
Relationship with the post's channel.
BelongsTo
user()
Relationship with the post's author.
HasMany
comments()
Relationship with the post's comments.
HasOne
lastComment()
Relationship with the post's most recent comment.
BelongsTo
answer()
Relationship with the post's answer comment.
BelongsToMany
tags()
Relationship with the post's tags.
string
urlAtIndex(int $index = 0)
Generate a URL for a particular comment index in this post.
Post
markAsEdited()
Mark this post as having been edited just now.
Post
refreshCommentMetadata()
Refresh the metadata about this post's comments.
bool
isUnread()
Determine whether this post contains any new activity for the current user.
bool
isRead()
Determine whether this post has been fully read by the current user.
bool
isNew()
Determine whether this post has never before been seen by the current user.
array
streamUpdated()
Get the Turbo Streams that should be sent when this post is updated.
array
streamRemoved()
Get the Turbo Streams that should be sent when this post is removed.
int
getPerPage()
No description
string
getRouteKey()
No description
resolveRouteBinding($value, $field = null)
No description
protected Attribute
url()
No description
protected Attribute
editUrl()
No description
protected Attribute
unreadUrl()
No description
string
reactionsUrl(ReactionType $reactionType)
No description