1
0
mirror of https://github.com/flarum/core.git synced 2025-08-10 18:35:56 +02:00

Use Eloquent's latest and oldest

This commit is contained in:
Toby Zerner
2018-07-21 17:21:08 +09:30
parent 7d0813bce4
commit ff7f7681c7
3 changed files with 4 additions and 4 deletions

View File

@@ -223,7 +223,7 @@ class Discussion extends AbstractModel
public function refreshLastPost()
{
/** @var Post $lastPost */
if ($lastPost = $this->comments()->latest('created_at')->first()) {
if ($lastPost = $this->comments()->latest()->first()) {
$this->setLastPost($lastPost);
}
@@ -269,7 +269,7 @@ class Discussion extends AbstractModel
*/
public function mergePost(MergeableInterface $post)
{
$lastPost = $this->posts()->latest('created_at')->first();
$lastPost = $this->posts()->latest()->first();
$post = $post->saveAfter($lastPost);