PHP Class Flarum\Core\Discussion

Inheritance: extends Flarum\Database\AbstractModel, use trait Flarum\Core\Support\EventGeneratorTrait, use trait Flarum\Core\Support\ScopeVisibilityTrait
Datei anzeigen Open project: flarum/core Class Usage Examples

Protected Properties

Property Type Description
$dates
$modifiedPosts array An array of posts that have been modified during this request.
$stateUser User The user for which the state relationship should be loaded.
$table

Public Methods

Method Description
boot ( ) : void Boot the model.
comments ( ) : Illuminate\Database\Eloquent\Relations\HasMany Define the relationship with the discussion's publicly-visible comments.
getModifiedPosts ( ) : array Get the posts that have been modified during this request.
hide ( User $actor = null ) Hide the discussion.
lastPost ( ) : BelongsTo Define the relationship with the discussion's last post.
lastUser ( ) : BelongsTo Define the relationship with the discussion's most recent author.
mergePost ( Flarum\Core\Post\MergeableInterface $post ) : Post Save a post, attempting to merge it with the discussion's last post.
participants ( ) : Builder Query the discussion's participants (a list of unique users who have posted in the discussion).
posts ( ) : Illuminate\Database\Eloquent\Relations\HasMany Define the relationship with the discussion's posts.
postsVisibleTo ( User $user ) : Illuminate\Database\Eloquent\Relations\HasMany Define the relationship with the discussion's posts, but only ones which are visible to the given user.
readers ( ) : BelongsTo Define the relationship with the discussion's readers.
refreshCommentsCount ( ) Refresh the discussion's comments count.
refreshLastPost ( ) Refresh a discussion's last post details.
refreshParticipantsCount ( ) Refresh the discussion's participants count.
rename ( string $title ) Rename the discussion. Raises the DiscussionWasRenamed event.
restore ( ) Restore the discussion.
setLastPost ( Post $post ) Set the discussion's last post details.
setStartPost ( Post $post ) Set the discussion's start post details.
setStateUser ( User $user ) Set the user for which the state relationship should be loaded.
start ( string $title, User $user ) : static Start a new discussion. Raises the DiscussionWasStarted event.
startPost ( ) : BelongsTo Define the relationship with the discussion's first post.
startUser ( ) : BelongsTo Define the relationship with the discussion's author.
state ( User $user = null ) : Illuminate\Database\Eloquent\Relations\HasOne Define the relationship with the discussion's state for a particular user.
stateFor ( User $user ) : DiscussionState Get the state model for a user, or instantiate a new one if it does not exist.

Protected Methods

Method Description
setTitleAttribute ( string $title ) Set the discussion title.

Method Details

boot() public static method

Boot the model.
public static boot ( ) : void
return void

comments() public method

Define the relationship with the discussion's publicly-visible comments.
public comments ( ) : Illuminate\Database\Eloquent\Relations\HasMany
return Illuminate\Database\Eloquent\Relations\HasMany

getModifiedPosts() public method

Get the posts that have been modified during this request.
public getModifiedPosts ( ) : array
return array

hide() public method

Hide the discussion.
public hide ( User $actor = null )
$actor User

lastPost() public method

Define the relationship with the discussion's last post.
public lastPost ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

lastUser() public method

Define the relationship with the discussion's most recent author.
public lastUser ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

mergePost() public method

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.)
public mergePost ( Flarum\Core\Post\MergeableInterface $post ) : Post
$post Flarum\Core\Post\MergeableInterface The post to save.
return Post 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.

participants() public method

Query the discussion's participants (a list of unique users who have posted in the discussion).
public participants ( ) : Builder
return Illuminate\Database\Eloquent\Builder

posts() public method

Define the relationship with the discussion's posts.
public posts ( ) : Illuminate\Database\Eloquent\Relations\HasMany
return Illuminate\Database\Eloquent\Relations\HasMany

postsVisibleTo() public method

Define the relationship with the discussion's posts, but only ones which are visible to the given user.
public postsVisibleTo ( User $user ) : Illuminate\Database\Eloquent\Relations\HasMany
$user User
return Illuminate\Database\Eloquent\Relations\HasMany

readers() public method

Define the relationship with the discussion's readers.
public readers ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

refreshCommentsCount() public method

Refresh the discussion's comments count.

refreshLastPost() public method

Refresh a discussion's last post details.
public refreshLastPost ( )

refreshParticipantsCount() public method

Refresh the discussion's participants count.

rename() public method

Rename the discussion. Raises the DiscussionWasRenamed event.
public rename ( string $title )
$title string

restore() public method

Restore the discussion.
public restore ( )

setLastPost() public method

Set the discussion's last post details.
public setLastPost ( Post $post )
$post Post

setStartPost() public method

Set the discussion's start post details.
public setStartPost ( Post $post )
$post Post

setStateUser() public static method

Set the user for which the state relationship should be loaded.
public static setStateUser ( User $user )
$user User

setTitleAttribute() protected method

This automatically creates a matching slug for the discussion.
protected setTitleAttribute ( string $title )
$title string

start() public static method

Start a new discussion. Raises the DiscussionWasStarted event.
public static start ( string $title, User $user ) : static
$title string
$user User
return static

startPost() public method

Define the relationship with the discussion's first post.
public startPost ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

startUser() public method

Define the relationship with the discussion's author.
public startUser ( ) : BelongsTo
return Illuminate\Database\Eloquent\Relations\BelongsTo

state() public method

If no user is passed (i.e. in the case of eager loading the 'state' relation), then the static $stateUser property is used.
See also: Discussion::setStateUser()
public state ( User $user = null ) : Illuminate\Database\Eloquent\Relations\HasOne
$user User
return Illuminate\Database\Eloquent\Relations\HasOne

stateFor() public method

Get the state model for a user, or instantiate a new one if it does not exist.
public stateFor ( User $user ) : DiscussionState
$user User
return DiscussionState

Property Details

$dates protected_oe property

protected $dates

$modifiedPosts protected_oe property

An array of posts that have been modified during this request.
protected array $modifiedPosts
return array

$stateUser protected_oe static_oe property

The user for which the state relationship should be loaded.
protected static User,Flarum\Core $stateUser
return User

$table protected_oe property

protected $table