PHP Class Flarum\Core\Discussion

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

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode Description
setTitleAttribute ( string $title ) Set the discussion title.

Method Details

boot() public static méthode

Boot the model.
public static boot ( ) : void
Résultat void

comments() public méthode

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

getModifiedPosts() public méthode

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

hide() public méthode

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

lastPost() public méthode

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

lastUser() public méthode

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

mergePost() public méthode

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.
Résultat 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 méthode

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

posts() public méthode

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

postsVisibleTo() public méthode

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
Résultat Illuminate\Database\Eloquent\Relations\HasMany

readers() public méthode

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

refreshCommentsCount() public méthode

Refresh the discussion's comments count.

refreshLastPost() public méthode

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

refreshParticipantsCount() public méthode

Refresh the discussion's participants count.

rename() public méthode

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

restore() public méthode

Restore the discussion.
public restore ( )

setLastPost() public méthode

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

setStartPost() public méthode

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

setStateUser() public static méthode

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

setTitleAttribute() protected méthode

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

start() public static méthode

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

startPost() public méthode

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

startUser() public méthode

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

state() public méthode

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
Résultat Illuminate\Database\Eloquent\Relations\HasOne

stateFor() public méthode

Get the state model for a user, or instantiate a new one if it does not exist.
public stateFor ( User $user ) : DiscussionState
$user User
Résultat 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
Résultat array

$stateUser protected_oe static_oe property

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

$table protected_oe property

protected $table