diff --git a/framework/core/js/src/common/models/Discussion.js b/framework/core/js/src/common/models/Discussion.js index e57eafab9..7634e47d9 100644 --- a/framework/core/js/src/common/models/Discussion.js +++ b/framework/core/js/src/common/models/Discussion.js @@ -11,7 +11,7 @@ Object.assign(Discussion.prototype, { startTime: Model.attribute('startTime', Model.transformDate), startUser: Model.hasOne('startUser'), - startPost: Model.hasOne('startPost'), + firstPost: Model.hasOne('firstPost'), lastTime: Model.attribute('lastTime', Model.transformDate), lastUser: Model.hasOne('lastUser'), diff --git a/framework/core/js/src/forum/components/DiscussionListItem.js b/framework/core/js/src/forum/components/DiscussionListItem.js index c395c72f9..1f4f663bf 100644 --- a/framework/core/js/src/forum/components/DiscussionListItem.js +++ b/framework/core/js/src/forum/components/DiscussionListItem.js @@ -156,7 +156,7 @@ export default class DiscussionListItem extends Component { * * @return {Boolean} */ - showStartPost() { + showFirstPost() { return ['newest', 'oldest'].indexOf(this.props.params.sort) !== -1; } @@ -192,7 +192,7 @@ export default class DiscussionListItem extends Component { const items = new ItemList(); if (this.props.params.q) { - const post = this.props.discussion.mostRelevantPost() || this.props.discussion.startPost(); + const post = this.props.discussion.mostRelevantPost() || this.props.discussion.firstPost(); if (post && post.contentType() === 'comment') { const excerpt = highlight(post.contentPlain(), this.highlightRegExp, 175); @@ -202,7 +202,7 @@ export default class DiscussionListItem extends Component { items.add('terminalPost', TerminalPost.component({ discussion: this.props.discussion, - lastPost: !this.showStartPost() + lastPost: !this.showFirstPost() }) ); } diff --git a/framework/core/src/Api/Controller/CreateDiscussionController.php b/framework/core/src/Api/Controller/CreateDiscussionController.php index a58418a1e..2451b8cc9 100644 --- a/framework/core/src/Api/Controller/CreateDiscussionController.php +++ b/framework/core/src/Api/Controller/CreateDiscussionController.php @@ -33,7 +33,7 @@ class CreateDiscussionController extends AbstractCreateController 'posts', 'startUser', 'lastUser', - 'startPost', + 'firstPost', 'lastPost' ]; diff --git a/framework/core/src/Api/Controller/ListDiscussionsController.php b/framework/core/src/Api/Controller/ListDiscussionsController.php index f01e3ace6..a30e37223 100644 --- a/framework/core/src/Api/Controller/ListDiscussionsController.php +++ b/framework/core/src/Api/Controller/ListDiscussionsController.php @@ -40,7 +40,7 @@ class ListDiscussionsController extends AbstractListController * {@inheritdoc} */ public $optionalInclude = [ - 'startPost', + 'firstPost', 'lastPost' ]; @@ -98,7 +98,7 @@ class ListDiscussionsController extends AbstractListController $results = $results->getResults()->load($load); - if ($relations = array_intersect($load, ['startPost', 'lastPost'])) { + if ($relations = array_intersect($load, ['firstPost', 'lastPost'])) { foreach ($results as $discussion) { foreach ($relations as $relation) { if ($discussion->$relation) { diff --git a/framework/core/src/Api/Controller/ShowDiscussionController.php b/framework/core/src/Api/Controller/ShowDiscussionController.php index 33fc20477..545fdfbcc 100644 --- a/framework/core/src/Api/Controller/ShowDiscussionController.php +++ b/framework/core/src/Api/Controller/ShowDiscussionController.php @@ -54,7 +54,7 @@ class ShowDiscussionController extends AbstractShowController public $optionalInclude = [ 'startUser', 'lastUser', - 'startPost', + 'firstPost', 'lastPost' ]; diff --git a/framework/core/src/Api/Serializer/BasicDiscussionSerializer.php b/framework/core/src/Api/Serializer/BasicDiscussionSerializer.php index 026082a23..cb3ad2fe1 100644 --- a/framework/core/src/Api/Serializer/BasicDiscussionSerializer.php +++ b/framework/core/src/Api/Serializer/BasicDiscussionSerializer.php @@ -52,7 +52,7 @@ class BasicDiscussionSerializer extends AbstractSerializer /** * @return \Tobscure\JsonApi\Relationship */ - protected function startPost($discussion) + protected function firstPost($discussion) { return $this->hasOne($discussion, BasicPostSerializer::class); } diff --git a/framework/core/src/Discussion/Command/StartDiscussionHandler.php b/framework/core/src/Discussion/Command/StartDiscussionHandler.php index bc4fbb47b..cbc7f9559 100644 --- a/framework/core/src/Discussion/Command/StartDiscussionHandler.php +++ b/framework/core/src/Discussion/Command/StartDiscussionHandler.php @@ -94,7 +94,7 @@ class StartDiscussionHandler // attributes as posting the reply will have changed some of them (e.g. // last_time.) $discussion->setRawAttributes($post->discussion->getAttributes(), true); - $discussion->setStartPost($post); + $discussion->setFirstPost($post); $discussion->setLastPost($post); $this->dispatchEventsFor($discussion, $actor); diff --git a/framework/core/src/Discussion/Discussion.php b/framework/core/src/Discussion/Discussion.php index 60d529b6d..7eea9f561 100644 --- a/framework/core/src/Discussion/Discussion.php +++ b/framework/core/src/Discussion/Discussion.php @@ -46,7 +46,7 @@ use Flarum\Util\Str; * @property \Illuminate\Database\Eloquent\Collection $posts * @property \Illuminate\Database\Eloquent\Collection $comments * @property \Illuminate\Database\Eloquent\Collection $participants - * @property Post|null $startPost + * @property Post|null $firstPost * @property User|null $startUser * @property Post|null $lastPost * @property User|null $lastUser @@ -184,12 +184,12 @@ class Discussion extends AbstractModel } /** - * Set the discussion's start post details. + * Set the discussion's first post details. * * @param Post $post * @return $this */ - public function setStartPost(Post $post) + public function setFirstPost(Post $post) { $this->created_at = $post->created_at; $this->user_id = $post->user_id; @@ -329,7 +329,7 @@ class Discussion extends AbstractModel * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ - public function startPost() + public function firstPost() { return $this->belongsTo(Post::class, 'first_post_id'); } diff --git a/framework/core/tests/Test/Concerns/ManagesContent.php b/framework/core/tests/Test/Concerns/ManagesContent.php index 9d1d687cb..80437c7fc 100644 --- a/framework/core/tests/Test/Concerns/ManagesContent.php +++ b/framework/core/tests/Test/Concerns/ManagesContent.php @@ -31,8 +31,8 @@ trait ManagesContent $post->save(); - if (! $this->discussion->startPost) { - $this->discussion->setStartPost($post); + if (! $this->discussion->firstPost) { + $this->discussion->setFirstPost($post); $this->discussion->setLastPost($post); $this->discussion->save();