Update Post and Topic models

This commit is contained in:
Visman 2020-06-06 20:14:59 +07:00
parent d407c9310d
commit 84fc2cf463
2 changed files with 14 additions and 2 deletions

View file

@ -22,7 +22,13 @@ class Model extends DataModel
throw new RuntimeException('Parent is not defined');
}
return $this->c->topics->load($this->topic_id);
$topic = $this->c->topics->load($this->topic_id);
if (! $topic instanceof Topic || $topic->moved_to || ! $topic->parent) {
throw new RuntimeException("Parent({$this->topic_id}) is broken for post number {$this->id}");
}
return $topic;
}
/**

View file

@ -22,7 +22,13 @@ class Model extends DataModel
throw new RuntimeException('Parent is not defined');
}
return $this->c->forums->get($this->forum_id);
$forum = $this->c->forums->get($this->forum_id);
if (! $forum instanceof Forum || $forum->redirect_url) {
throw new RuntimeException("Parent({$this->forum_id}) is broken for topic number {$this->id}");
}
return $forum;
}
/**