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 | $dateAttributes | from AbstractModel |
|
|
| static | $defaults | from AbstractModel |
|
|
| 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 | $stateUser | The user for which the state relationship should be loaded. |
|
|
| int | $id |
|
||
| 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 95
static
boot()
Boot the model.
in AbstractModel
at
line 85
__construct(array $attributes = [])
{@inheritdoc}
in AbstractModel
at
line 105
array
getDates()
Get the attributes that should be converted to dates.
in AbstractModel
at
line 123
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 149
protected mixed
getCustomRelation(string $name)
Get a custom relation object.
in AbstractModel
at
line 165
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 176
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 184
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 196
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 208
__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 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 121
static Discussion
start(string $title, User $user)
Start a new discussion. Raises the DiscussionWasStarted event.
at
line 142
$this
rename(string $title)
Rename the discussion. Raises the DiscussionWasRenamed event.
at
line 177
$this
restore()
Restore the discussion.
at
line 225
$this
refreshLastPost()
Refresh a discussion's last post details.
at
line 240
$this
refreshCommentCount()
Refresh the discussion's comment count.
at
line 252
$this
refreshParticipantCount()
Refresh the discussion's participant count.
at
line 272
Post
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 286
array
getModifiedPosts()
Get the posts that have been modified during this request.
at
line 296
HasMany
posts()
Define the relationship with the discussion's posts.
at
line 306
HasMany
comments()
Define the relationship with the discussion's publicly-visible comments.
at
line 320
Builder
participants()
Query the discussion's participants (a list of unique users who have posted in the discussion).
at
line 335
BelongsTo
firstPost()
Define the relationship with the discussion's first post.
at
line 345
BelongsTo
user()
Define the relationship with the discussion's author.
at
line 355
BelongsTo
lastPost()
Define the relationship with the discussion's last post.
at
line 365
BelongsTo
lastPostedUser()
Define the relationship with the discussion's most recent author.
at
line 375
BelongsTo
mostRelevantPost()
Define the relationship with the discussion's most relevant post.
at
line 385
BelongsToMany
readers()
Define the relationship with the discussion's readers.
at
line 402
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 416
UserState
stateFor(User $user)
Get the state model for a user, or instantiate a new one if it does not exist.
at
line 434
static
setStateUser(User $user)
Set the user for which the state relationship should be loaded.
at
line 447
protected
setTitleAttribute(string $title)
Set the discussion title.
This automatically creates a matching slug for the discussion.