Skip to content

Commit

Permalink
#311 parent (질문) 조회 시 확장 필드 값을 같이 가져오도록 코드를 수정합니다.
Browse files Browse the repository at this point in the history
  • Loading branch information
xharpenParksuhyeon committed Aug 20, 2021
1 parent 146672d commit 79cc6da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/Controllers/BoardModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,9 @@ public function create(
throw new DisabledReplyException;
}

$parentBoard = Board::where('instance_id', $this->instanceId)->findOrFail($parentId);
$parentBoard = Board::division($this->config->get('boardId'))
->where('instance_id', $this->instanceId)
->findOrFail($parentId);

if ($parentBoard->isNotice()) {
throw new CanNotReplyNoticeException;
Expand Down
11 changes: 10 additions & 1 deletion src/Models/Board.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,16 @@ public function existsReplies(): bool
*/
public function findParentDoc()
{
return $this->hasParentDoc() ? Board::with('replies', 'data')->find($this->parent_id) : null;
if ($this->hasParentDoc()) {
/** @var Board $parentDoc */
$parentDoc = Board::division($this->instance_id)->find($this->parent_id);

if ($parentDoc instanceof Board) {
return $parentDoc->load('replies', 'data');
}
}

return null;
}

/**
Expand Down

0 comments on commit 79cc6da

Please sign in to comment.