class Discussion extends AbstractModel
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 | $customCasts | from AbstractModel |
|
|
| static | $defaults | from AbstractModel |
|
|
| protected string|null | $tableAlias | An alias for the table name, used in queries. | from AbstractModel |
|
| int | $id |
|
||
| protected array | $pendingEvents | from EventGeneratorTrait |
|
|
| static protected | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected array | $modifiedPosts | An array of posts that have been modified during this request. |
|
|
| protected array | $dates | The attributes that should be mutated to dates. |
|
|
| protected array | $casts | The attributes that should be cast to native types. |
|
|
| static protected User|null | $stateUser | The user for which the state relationship should be loaded. |
|
|
| string | $title |
|
||
| string | $slug |
|
||
| int | $comment_count |
|
||
| int | $participant_count |
|
||
| int | $post_number_index | !!DEPRECATED!! |
|
|
| Carbon | $created_at |
|
||
| int|null | $user_id |
|
||
| int|null | $first_post_id |
|
||
| Carbon|null | $last_posted_at |
|
||
| int|null | $last_posted_user_id |
|
||
| int|null | $last_post_id |
|
||
| int|null | $last_post_number |
|
||
| $hidden_at |
|
|||
| $hidden_user_id |
|
|||
| UserState|null | $state |
|
||
| Collection | $posts |
|
||
| Collection | $comments |
|
||
| Collection | $participants |
|
||
| Post|null | $firstPost |
|
||
| User|null | $user |
|
||
| Post|null | $lastPost |
|
||
| User|null | $lastPostedUser |
|
||
| Collection | $readers |
|
||
| bool | $is_private |
|
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.
Save a post, attempting to merge it with the discussion's last post.
Query the discussion's participants (a list of unique users who have posted in the discussion).
Details
at
line 96
static
boot()
Boot the model.
in AbstractModel
at
line 97
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 115
getCasts()
{@inheritdoc}
in AbstractModel
at
line 133
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 159
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 175
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 186
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 194
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 206
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 218
__call($method, $arguments)
{@inheritdoc}
in AbstractModel
at
line 227
newModelQuery()
in AbstractModel
at
line 238
qualifyColumn($column)
in AbstractModel
at
line 247
withTableAlias(callable $callback)
in AbstractModel
at
line 262
newCollection(Collection|array $models = [])
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 20
static
registerVisibilityScoper($scoper, $ability = null)
in ScopeVisibilityTrait
at
line 41
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
Scope a query to only include records that are visible to a user.
at
line 122
static Discussion
start(string $title, User $user)
Start a new discussion. Raises the DiscussionWasStarted event.
at
line 143
$this
rename(string $title)
Rename the discussion. Raises the DiscussionWasRenamed event.
at
line 178
$this
restore()
Restore the discussion.
at
line 226
$this
refreshLastPost()
Refresh a discussion's last post details.
at
line 241
$this
refreshCommentCount()
Refresh the discussion's comment count.
at
line 253
$this
refreshParticipantCount()
Refresh the discussion's participant count.
at
line 274
T
mergePost(MergeableInterface $post)
Save a post, attempting to merge it with the discussion's last post.
The merge logic is delegated to the new post. (As an example, a DiscussionRenamedPost will merge if adjacent to another DiscussionRenamedPost, and delete if the title has been reverted completely.)
at
line 288
array
getModifiedPosts()
Get the posts that have been modified during this request.
at
line 298
HasMany
posts()
Define the relationship with the discussion's posts.
at
line 308
Post>
comments()
Define the relationship with the discussion's publicly-visible comments.
at
line 322
Builder
participants()
Query the discussion's participants (a list of unique users who have posted in the discussion).
at
line 337
BelongsTo
firstPost()
Define the relationship with the discussion's first post.
at
line 347
BelongsTo
user()
Define the relationship with the discussion's author.
at
line 357
BelongsTo
lastPost()
Define the relationship with the discussion's last post.
at
line 367
BelongsTo
lastPostedUser()
Define the relationship with the discussion's most recent author.
at
line 377
BelongsTo
mostRelevantPost()
Define the relationship with the discussion's most relevant post.
at
line 387
BelongsToMany
readers()
Define the relationship with the discussion's readers.
at
line 404
HasOne
state(User $user = null)
Define the relationship with the discussion's state for a particular user.
If no user is passed (i.e. in the case of eager loading the 'state' relation), then the static `$stateUser` property is used.
at
line 415
UserState
stateFor(User $user)
Get the state model for a user, or instantiate a new one if it does not exist.
at
line 432
static
setStateUser(User $user)
Set the user for which the state relationship should be loaded.
at
line 442
protected
setTitleAttribute(string $title)
Set the discussion title.
This automatically creates a matching slug for the discussion.