mirror of
https://github.com/flarum/framework.git
synced 2024-12-13 07:03:35 +08:00
Update start_post_id when starting a discussion
This commit is contained in:
parent
649fbf3377
commit
046c6e2168
|
@ -44,9 +44,12 @@ class StartDiscussionCommandHandler
|
|||
// attributes as posting the reply will have changed some of them (e.g.
|
||||
// last_time.)
|
||||
$discussion->setRawAttributes($post->discussion->getAttributes(), true);
|
||||
$discussion->setStartPost($post);
|
||||
|
||||
$this->dispatchEventsFor($discussion);
|
||||
|
||||
$discussion->save();
|
||||
|
||||
return $post->discussion;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,6 +134,21 @@ class Discussion extends Model
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the discussion's start post details.
|
||||
*
|
||||
* @param \Flarum\Core\Models\Post $post
|
||||
* @return $this
|
||||
*/
|
||||
public function setStartPost(Post $post)
|
||||
{
|
||||
$this->start_time = $post->time;
|
||||
$this->start_user_id = $post->user_id;
|
||||
$this->start_post_id = $post->id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the discussion's last post details.
|
||||
*
|
||||
|
@ -350,6 +365,10 @@ class Discussion extends Model
|
|||
*/
|
||||
public function stateFor(User $user)
|
||||
{
|
||||
// If the state is already eager-loaded, we'll return that.
|
||||
// Unfortunately we can't check to see if the user ID is the same,
|
||||
// because the user may not have a state entry, in which case the loaded
|
||||
// relation will be null.
|
||||
if ($this->isRelationLoaded('state')) {
|
||||
return $this->relations['state'];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user