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 array | $customCasts | from AbstractModel |
|
|
| static array | $defaults | from AbstractModel |
|
|
| static protected array<class-string, array<string, string>> | $castsCache | Resolved casts, keyed by model class. | from AbstractModel |
|
| protected string|null | $tableAlias | An alias for the table name, used in queries. | from AbstractModel |
|
| string[]|null | $uniqueKeys | If a model has unique keys, they should be defined here. | from AbstractModel |
|
| protected array | $pendingEvents | from EventGeneratorTrait |
|
|
| static protected Builder, ?string): void>> | $visibilityScopers | from ScopeVisibilityTrait |
|
|
| protected array | $modifiedPosts | An array of posts that have been modified during this request. |
|
|
| protected | $casts |
|
||
| protected | $observables |
|
||
| static protected User|null | $stateUser | The user for which the state relationship should be loaded. |
|
|
| 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
Discard the resolved casts, so that newly registered ones are picked up.
Register a callback to be run once after the model is saved.
Register a callback to be run once after the model is deleted.
No description
Scope a query to only include records that are visible to a user.
Start a new discussion. Raises the DiscussionWasStarted event.
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()
in AbstractModel
at
line 100
__construct(array $attributes = [])
in AbstractModel
at
line 115
array
getCasts()
in AbstractModel
at
line 135
static void
flushCastsCache()
Discard the resolved casts, so that newly registered ones are picked up.
in AbstractModel
at
line 143
void
afterSave(callable $callback)
Register a callback to be run once after the model is saved.
in AbstractModel
at
line 151
void
afterDelete(callable $callback)
Register a callback to be run once after the model is deleted.
in AbstractModel
at
line 159
array
releaseAfterSaveCallbacks()
in AbstractModel
at
line 171
array
releaseAfterDeleteCallbacks()
in AbstractModel
at
line 183
newModelQuery()
in AbstractModel
at
line 195
qualifyColumn($column)
in AbstractModel
at
line 204
mixed
withTableAlias(callable $callback)
in AbstractModel
at
line 217
Collection
newCollection(array $models = [])
in AbstractModel
at
line 223
__sleep()
in EventGeneratorTrait
at
line 16
void
raise(object $event)
in EventGeneratorTrait
at
line 24
array
releaseEvents()
Return and reset all pending events.
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')
Scope a query to only include records that are visible to a user.
in ScopeVisibilityTrait
at
line 19
static Builder
whereVisibleTo( User $user)
at
line 120
static Discussion
start(string|null $title, User $user, Discussion|null $model = null)
Start a new discussion. Raises the DiscussionWasStarted event.
at
line 138
Discussion
rename(string $title)
at
line 150
Discussion
hide( User|null $actor = null)
at
line 168
Discussion
restore()
at
line 186
Discussion
setFirstPost( Post $post)
at
line 195
Discussion
setLastPost( Post $post)
at
line 205
Discussion
refreshLastPost()
at
line 215
Discussion
refreshCommentCount()
at
line 222
Discussion
refreshParticipantCount()
at
line 243
MergeableInterface
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 257
array
getModifiedPosts()
Get the posts that have been modified during this request.
at
line 287
Builder
participants()
Query the discussion's participants (a list of unique users who have posted in the discussion).
at
line 325
BelongsToMany
readers()
at
line 336
HasOne
state( User|null $user = null)
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 347
UserState
stateFor( User $user)
Get the state model for a user, or instantiate a new one if it does not exist.
at
line 364
static void
setStateUser( User $user)
Set the user for which the state relationship should be loaded.
at
line 374
protected void
setTitleAttribute(string $title)
Set the discussion title.
This automatically creates a matching slug for the discussion.