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
protected array $pendingEvents from EventGeneratorTrait
protected $table <p>{@inheritdoc}</p>
protected array $modifiedPosts <p>An array of posts that have been modified during this request.</p>
protected $dates <p>{@inheritdoc}</p>
static protected User $stateUser <p>The user for which the state relationship should be loaded.</p>
int $id
string $title
int $comments_count
int $participants_count
int $number_index
Carbon $start_time
int|null $start_user_id
int|null $start_post_id
Carbon|null $last_time
int|null $last_user_id
int|null $last_post_id
int|null $last_post_number
Carbon|null $hide_time
int|null $hide_user_id
DiscussionState|null $state
Collection $posts
Collection $comments
Collection $participants
Post|null $startPost
User|null $startUser
Post|null $lastPost
User|null $lastUser
Collection $readers

Methods

static 
boot()

<p>Boot the model.</p>

array
getDates()

<p>Get the attributes that should be converted to dates.</p>

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>

mixed
getCustomRelation(string $name)

<p>Get a custom relation object.</p>

void
afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

void
afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

callable[]
releaseAfterSaveCallbacks()

No description

callable[]
releaseAfterDeleteCallbacks()

No description

__call($method, $arguments)

<p>{@inheritdoc}</p>

raise(mixed $event)

<p>Raise a new event.</p>

array
releaseEvents()

<p>Return and reset all pending events.</p>

scopeWhereVisibleTo(Builder $query, User $actor)

<p>Scope a query to only include records that are visible to a user.</p>

static Discussion
start(string $title, User $user)

<p>Start a new discussion. Raises the DiscussionWasStarted event.</p>

$this
rename(string $title)

<p>Rename the discussion. Raises the DiscussionWasRenamed event.</p>

$this
hide(User $actor = null)

<p>Hide the discussion.</p>

$this
restore()

<p>Restore the discussion.</p>

$this
setStartPost(Post $post)

<p>Set the discussion's start post details.</p>

$this
setLastPost(Post $post)

<p>Set the discussion's last post details.</p>

$this
refreshLastPost()

<p>Refresh a discussion's last post details.</p>

$this
refreshCommentsCount()

<p>Refresh the discussion's comments count.</p>

$this
refreshParticipantsCount()

<p>Refresh the discussion's participants count.</p>

mergePost(MergeableInterface $post)

<p>Save a post, attempting to merge it with the discussion's last post.</p>

array
getModifiedPosts()

<p>Get the posts that have been modified during this request.</p>

HasMany
posts()

<p>Define the relationship with the discussion's posts.</p>

HasMany
postsVisibleTo(User $user)

<p>Define the relationship with the discussion's posts, but only ones which are visible to the given user.</p>

HasMany
comments()

<p>Define the relationship with the discussion's publicly-visible comments.</p>

Builder
participants()

<p>Query the discussion's participants (a list of unique users who have posted in the discussion).</p>

BelongsTo
startPost()

<p>Define the relationship with the discussion's first post.</p>

BelongsTo
startUser()

<p>Define the relationship with the discussion's author.</p>

BelongsTo
lastPost()

<p>Define the relationship with the discussion's last post.</p>

BelongsTo
lastUser()

<p>Define the relationship with the discussion's most recent author.</p>

BelongsTo
readers()

<p>Define the relationship with the discussion's readers.</p>

HasOne
state(User $user = null)

<p>Define the relationship with the discussion's state for a particular user.</p>

stateFor(User $user)

<p>Get the state model for a user, or instantiate a new one if it does not exist.</p>

static 
setStateUser(User $user)

<p>Set the user for which the state relationship should be loaded.</p>

Details

static boot()

<p>Boot the model.</p>

array getDates()

<p>Get the attributes that should be converted to dates.</p>

Return Value

array

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>

Parameters

string $key

Return Value

mixed

protected mixed getCustomRelation(string $name)

<p>Get a custom relation object.</p>

Parameters

string $name

Return Value

mixed

void afterSave(callable $callback)

<p>Register a callback to be run once after the model is saved.</p>

Parameters

callable $callback

Return Value

void

void afterDelete(callable $callback)

<p>Register a callback to be run once after the model is deleted.</p>

Parameters

callable $callback

Return Value

void

callable[] releaseAfterSaveCallbacks()

Return Value

callable[]

callable[] releaseAfterDeleteCallbacks()

Return Value

callable[]

__call($method, $arguments)

<p>{@inheritdoc}</p>

Parameters

$method
$arguments

raise(mixed $event)

<p>Raise a new event.</p>

Parameters

mixed $event

array releaseEvents()

<p>Return and reset all pending events.</p>

Return Value

array

scopeWhereVisibleTo(Builder $query, User $actor)

<p>Scope a query to only include records that are visible to a user.</p>

Parameters

Builder $query
User $actor

static Discussion start(string $title, User $user)

<p>Start a new discussion. Raises the DiscussionWasStarted event.</p>

Parameters

string $title
User $user

Return Value

Discussion

$this rename(string $title)

<p>Rename the discussion. Raises the DiscussionWasRenamed event.</p>

Parameters

string $title

Return Value

$this

$this hide(User $actor = null)

<p>Hide the discussion.</p>

Parameters

User $actor

Return Value

$this

$this restore()

<p>Restore the discussion.</p>

Return Value

$this

$this setStartPost(Post $post)

<p>Set the discussion's start post details.</p>

Parameters

Post $post

Return Value

$this

$this setLastPost(Post $post)

<p>Set the discussion's last post details.</p>

Parameters

Post $post

Return Value

$this

$this refreshLastPost()

<p>Refresh a discussion's last post details.</p>

Return Value

$this

$this refreshCommentsCount()

<p>Refresh the discussion's comments count.</p>

Return Value

$this

$this refreshParticipantsCount()

<p>Refresh the discussion's participants count.</p>

Return Value

$this

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>

Parameters

MergeableInterface $post <p>The post to save.</p>

Return Value

Post <p>The resulting post. It may or may not be the same post as was originally intended to be saved. It also may not exist, if the merge logic resulted in deletion.</p>

array getModifiedPosts()

<p>Get the posts that have been modified during this request.</p>

Return Value

array

HasMany posts()

<p>Define the relationship with the discussion's posts.</p>

Return Value

HasMany

HasMany postsVisibleTo(User $user)

<p>Define the relationship with the discussion's posts, but only ones which are visible to the given user.</p>

Parameters

User $user

Return Value

HasMany

HasMany comments()

<p>Define the relationship with the discussion's publicly-visible comments.</p>

Return Value

HasMany

Builder participants()

<p>Query the discussion's participants (a list of unique users who have posted in the discussion).</p>

Return Value

Builder

BelongsTo startPost()

<p>Define the relationship with the discussion's first post.</p>

Return Value

BelongsTo

BelongsTo startUser()

<p>Define the relationship with the discussion's author.</p>

Return Value

BelongsTo

BelongsTo lastPost()

<p>Define the relationship with the discussion's last post.</p>

Return Value

BelongsTo

BelongsTo lastUser()

<p>Define the relationship with the discussion's most recent author.</p>

Return Value

BelongsTo

BelongsTo readers()

<p>Define the relationship with the discussion's readers.</p>

Return Value

BelongsTo

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>

Parameters

User $user

Return Value

HasOne

See also

Discussion::setStateUser

DiscussionState stateFor(User $user)

<p>Get the state model for a user, or instantiate a new one if it does not exist.</p>

Parameters

User $user

Return Value

DiscussionState

static setStateUser(User $user)

<p>Set the user for which the state relationship should be loaded.</p>

Parameters

User $user