user_id === $previous->user_id) { if ($previous->content['sticky'] != $this->content['sticky']) { $previous->delete(); } else { $previous->content = $this->content; $previous->save(); } return $previous; } $this->save(); return $this; } public static function reply(int $discussionId, int $userId, bool $isSticky): static { $post = new static; $post->content = static::buildContent($isSticky); $post->created_at = Carbon::now(); $post->discussion_id = $discussionId; $post->user_id = $userId; return $post; } public static function buildContent(bool $isSticky): array { return ['sticky' => $isSticky]; } }