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 | $customCasts | from AbstractModel | ||
static | $defaults | from AbstractModel | ||
protected | $tableAlias | <p>An alias for the table name, used in queries.</p> | from AbstractModel | |
protected | $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 | $casts | |||
protected | $observables | |||
static protected | $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 | |||
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 | ||||
bool | $is_private | |||
UserState|null | $state | |||
Collection | $posts | |||
Collection | $comments | |||
Collection | $participants | |||
Post|null | $firstPost | |||
User|null | $user | |||
Post|null | $lastPost | |||
User|null | $lastPostedUser | |||
Collection | $readers |
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>
No description
<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>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>
Details
at
line 94
static
boot()
in AbstractModel
at
line 88
__construct(array $attributes = [])
in AbstractModel
at
line 103
array
getCasts()
in AbstractModel
at
line 118
getAttribute($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 143
protected mixed
getCustomRelation(string $name)
<p>Get a custom relation object.</p>
in AbstractModel
at
line 158
void
afterSave(callable $callback)
<p>Register a callback to be run once after the model is saved.</p>
in AbstractModel
at
line 166
void
afterDelete(callable $callback)
<p>Register a callback to be run once after the model is deleted.</p>
in AbstractModel
at
line 174
array
releaseAfterSaveCallbacks()
in AbstractModel
at
line 186
array
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 195
__call($method, $parameters)
in AbstractModel
at
line 204
newModelQuery()
in AbstractModel
at
line 215
qualifyColumn($column)
in AbstractModel
at
line 224
mixed
withTableAlias(callable $callback)
in AbstractModel
at
line 236
Collection
newCollection(array $models = [])
in AbstractModel
at
line 241
__sleep()
in EventGeneratorTrait
at
line 16
void
raise(object $event)
in EventGeneratorTrait
at
line 24
array
releaseEvents()
<p>Return and reset all pending events.</p>
in ScopeVisibilityTrait
at
line 28
static void
registerVisibilityScoper(callable $scoper, string|null $ability = null)
in ScopeVisibilityTrait
at
line 44
Builder
scopeWhereVisibleTo(Builder $query, User $actor, string $ability = 'view')
<p>Scope a query to only include records that are visible to a user.</p>
in ScopeVisibilityTrait
at
line 19
static Builder
whereVisibleTo(User $user)
at
line 113
static Discussion
start(string $title, User $user)
at
line 128
Discussion
rename(string $title)
at
line 140
Discussion
hide(User|null $actor = null)
at
line 158
Discussion
restore()
at
line 176
Discussion
setFirstPost(Post $post)
at
line 185
Discussion
setLastPost(Post $post)
at
line 195
Discussion
refreshLastPost()
at
line 205
Discussion
refreshCommentCount()
at
line 212
Discussion
refreshParticipantCount()
at
line 233
MergeableInterface
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 247
array
getModifiedPosts()
<p>Get the posts that have been modified during this request.</p>
at
line 255
HasMany
posts()
at
line 265
HasMany
comments()
<p>The discussion's publicly-visible comments.</p>
at
line 279
Builder
participants()
<p>Query the discussion's participants (a list of unique users who have posted in the discussion).</p>
at
line 289
BelongsTo
firstPost()
at
line 294
BelongsTo
user()
at
line 299
BelongsTo
lastPost()
at
line 304
BelongsTo
lastPostedUser()
at
line 309
BelongsTo
mostRelevantPost()
at
line 317
BelongsToMany
readers()
at
line 328
HasOne
state(User|null $user = null)
<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 339
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 356
static void
setStateUser(User $user)
<p>Set the user for which the state relationship should be loaded.</p>
at
line 366
protected void
setTitleAttribute(string $title)
<p>Set the discussion title.</p>
<p>This automatically creates a matching slug for the discussion.</p>