class Discussion extends AbstractModel
Traits
Properties
bool | $timestamps | <p>Indicates if the model should be timestamped. Turn off by default.</p> | from AbstractModel | |
protected callable[] | $afterSaveCallbacks | <p>An array of callbacks to be run once after the model is saved.</p> | from AbstractModel | |
protected callable[] | $afterDeleteCallbacks | <p>An array of callbacks to be run once after the model is deleted.</p> | 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 | <p>An array of posts that have been modified during this request.</p> | ||
protected array | $dates | <p>The attributes that should be mutated to dates.</p> | ||
protected array | $casts | <p>The attributes that should be cast to native types.</p> | ||
static protected User | $stateUser | <p>The user for which the state relationship should be loaded.</p> | ||
int | $id | |||
string | $title | |||
string | $slug | |||
int | $comment_count | |||
int | $participant_count | |||
int | $post_number_index | <p>!!DEPRECATED!!</p> | ||
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
<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>
<p>Register a callback to be run once after the model is saved.</p>
<p>Register a callback to be run once after the model is deleted.</p>
<p>Scope a query to only include records that are visible to a user.</p>
<p>Save a post, attempting to merge it with the discussion's last post.</p>
<p>Query the discussion's participants (a list of unique users who have posted in the discussion).</p>
<p>Define the relationship with the discussion's most relevant post.</p>
Details
at
line 95
static
boot()
<p>Boot the model.</p>
in AbstractModel
at
line 85
__construct(array $attributes = [])
<p>{@inheritdoc}</p>
in AbstractModel
at
line 105
array
getDates()
<p>Get the attributes that should be converted to dates.</p>
in AbstractModel
at
line 123
mixed
getAttribute(string $key)
<p>Get an attribute from the model. If nothing is found, attempt to load a custom relation method with this key.</p>
in AbstractModel
at
line 149
protected mixed
getCustomRelation(string $name)
<p>Get a custom relation object.</p>
in AbstractModel
at
line 165
void
afterSave(callable $callback)
<p>Register a callback to be run once after the model is saved.</p>
in AbstractModel
at
line 176
void
afterDelete(callable $callback)
<p>Register a callback to be run once after the model is deleted.</p>
in AbstractModel
at
line 184
callable[]
releaseAfterSaveCallbacks()
in AbstractModel
at
line 196
callable[]
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 208
__call($method, $arguments)
<p>{@inheritdoc}</p>
in EventGeneratorTrait
at
line 24
raise(mixed $event)
<p>Raise a new event.</p>
in EventGeneratorTrait
at
line 34
array
releaseEvents()
<p>Return and reset all pending events.</p>
in ScopeVisibilityTrait
at
line 20
static
registerVisibilityScoper($scoper, $ability = null)
in ScopeVisibilityTrait
at
line 41
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
<p>Scope a query to only include records that are visible to a user.</p>
at
line 121
static Discussion
start(string $title, User $user)
<p>Start a new discussion. Raises the DiscussionWasStarted event.</p>
at
line 142
$this
rename(string $title)
<p>Rename the discussion. Raises the DiscussionWasRenamed event.</p>
at
line 177
$this
restore()
<p>Restore the discussion.</p>
at
line 225
$this
refreshLastPost()
<p>Refresh a discussion's last post details.</p>
at
line 240
$this
refreshCommentCount()
<p>Refresh the discussion's comment count.</p>
at
line 252
$this
refreshParticipantCount()
<p>Refresh the discussion's participant count.</p>
at
line 272
Post
mergePost(MergeableInterface $post)
<p>Save a post, attempting to merge it with the discussion's last post.</p>
<p>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.)</p>
at
line 286
array
getModifiedPosts()
<p>Get the posts that have been modified during this request.</p>
at
line 296
HasMany
posts()
<p>Define the relationship with the discussion's posts.</p>
at
line 306
HasMany
comments()
<p>Define the relationship with the discussion's publicly-visible comments.</p>
at
line 320
Builder
participants()
<p>Query the discussion's participants (a list of unique users who have posted in the discussion).</p>
at
line 335
BelongsTo
firstPost()
<p>Define the relationship with the discussion's first post.</p>
at
line 345
BelongsTo
user()
<p>Define the relationship with the discussion's author.</p>
at
line 355
BelongsTo
lastPost()
<p>Define the relationship with the discussion's last post.</p>
at
line 365
BelongsTo
lastPostedUser()
<p>Define the relationship with the discussion's most recent author.</p>
at
line 375
BelongsTo
mostRelevantPost()
<p>Define the relationship with the discussion's most relevant post.</p>
at
line 385
BelongsToMany
readers()
<p>Define the relationship with the discussion's readers.</p>
at
line 402
HasOne
state(User $user = null)
<p>Define the relationship with the discussion's state for a particular user.</p>
<p>If no user is passed (i.e. in the case of eager loading the 'state' relation), then the static <code>$stateUser</code> property is used.</p>
at
line 416
UserState
stateFor(User $user)
<p>Get the state model for a user, or instantiate a new one if it does not exist.</p>
at
line 434
static
setStateUser(User $user)
<p>Set the user for which the state relationship should be loaded.</p>
at
line 447
protected
setTitleAttribute(string $title)
<p>Set the discussion title.</p>
<p>This automatically creates a matching slug for the discussion.</p>