class DiscussionRenamedPost extends AbstractEventPost implements MergeableInterface
A post which indicates that a discussion's title was changed.
The content is stored as a sequential array containing the old title and the new title.
Traits
Properties
bool | $timestamps | Indicates if the model should be timestamped. Turn off by default. | from AbstractModel |
|
protected callable[] | $afterSaveCallbacks | An array of callbacks to be run once after the model is saved. | from AbstractModel |
|
protected callable[] | $afterDeleteCallbacks | An array of callbacks to be run once after the model is deleted. | from AbstractModel |
|
static | $customRelations | from AbstractModel |
|
|
static | $dateAttributes | from AbstractModel |
|
|
static | $defaults | from AbstractModel |
|
|
protected array | $pendingEvents | from EventGeneratorTrait |
|
|
protected | $table | from Post |
|
|
protected array | $dates | The attributes that should be mutated to dates. | from Post |
|
protected array | $casts | The attributes that should be cast to native types. | from Post |
|
static protected array | $models | A map of post types, as specified in the <code>type</code> column, to their classes. | from Post |
|
static | $type | {@inheritdoc} |
|
|
int | $id | from Post |
|
|
int | $discussion_id | from Post |
|
|
int | $number | from Post |
|
|
Carbon | $created_at | from Post |
|
|
int|null | $user_id | from Post |
|
|
array | $content | from AbstractEventPost |
|
|
Carbon|null | $edited_at | from Post |
|
|
int|null | $edited_user_id | from Post |
|
|
$hidden_at | from Post |
|
||
$hidden_user_id | from Post |
|
||
Discussion|null | $discussion | from Post |
|
|
User|null | $user | from Post |
|
|
User|null | $editedUser | from Post |
|
|
$hiddenUser | from Post |
|
||
string | $ip_address | from Post |
|
|
bool | $is_private | from Post |
|
Methods
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
Scope a query to only include records that are visible to a user.
Get all posts, regardless of their type, by removing the <code>RegisteredTypesScope</code> global scope constraints applied on this model.
Create a new model instance according to the post's type.
Unserialize the content attribute from the database's JSON value.
Serialize the content attribute to be stored in the database as JSON.
Create a new instance in reply to a discussion.
Details
in AbstractModel
at
line 76
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 96
array
getDates()
Get the attributes that should be converted to dates.
in AbstractModel
at
line 114
mixed
getAttribute(string $key)
Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.
in AbstractModel
at
line 140
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 156
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 167
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 175
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 187
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 199
__call($method, $arguments)
{@inheritdoc}
in EventGeneratorTrait
at
line 24
raise(mixed $event)
Raise a new event.
in EventGeneratorTrait
at
line 34
array
releaseEvents()
Return and reset all pending events.
in ScopeVisibilityTrait
at
line 24
scopeWhereVisibleTo(Builder $query, User $actor)
Scope a query to only include records that are visible to a user.
bool
isVisibleTo(User $user)
Determine whether or not this post is visible to the given user.
BelongsTo
editedUser()
Define the relationship with the user who edited the post.
Builder
scopeAllTypes(Builder $query)
Get all posts, regardless of their type, by removing the <code>RegisteredTypesScope</code> global scope constraints applied on this model.
Post|object
newFromBuilder(array $attributes = [], string|null $connection = null)
Create a new model instance according to the post's type.
static void
setModel(string $type, string $model)
Set the model for the given post type.
in AbstractEventPost
at
line 23
array
getContentAttribute(string $value)
Unserialize the content attribute from the database's JSON value.
in AbstractEventPost
at
line 33
setContentAttribute(string $value)
Serialize the content attribute to be stored in the database as JSON.
at
line 30
Post
saveAfter(Post $previous = null)
Save the model, given that it is going to appear immediately after the passed model.
at
line 62
static DiscussionRenamedPost
reply(int $discussionId, int $userId, string $oldTitle, string $newTitle)
Create a new instance in reply to a discussion.
at
line 81
static protected array
buildContent(string $oldTitle, string $newTitle)
Build the content attribute.