public function saveAfter(Post $previous) { // If the previous post is another 'discussion locked' post, and it's // by the same user, then we can merge this post into it. If we find // that we've in fact reverted the locked status, delete it. Otherwise, // update its content. if ($previous instanceof static && $this->user_id === $previous->user_id) { if ($previous->content['locked'] != $this->content['locked']) { $previous->delete(); } else { $previous->content = $this->content; $previous->save(); } return $previous; } $this->save(); return $this; }
public function saveAfter(Post $previous) { // If the previous post is another 'discussion tagged' post, and it's // by the same user, then we can merge this post into it. If we find // that we've in fact reverted the tag changes, delete it. Otherwise, // update its content. if ($previous instanceof static && $this->user_id === $previous->user_id) { if ($previous->content[0] == $this->content[1]) { $previous->delete(); } else { $previous->content = static::buildContent($previous->content[0], $this->content[1]); $previous->time = $this->time; $previous->save(); } return $previous; } $this->save(); return $this; }