public function setLastPostCache()
{
$lastPost = $this->posts()->last()->first();
if ($lastPost === null) {
$this->topic_last_post_id = null;
$this->topic_last_post_time = null;
$this->topic_last_poster_id = null;
$this->topic_last_poster_name = null;
$this->topic_last_poster_colour = null;
} else {
$this->topic_last_post_id = $lastPost->post_id;
$this->topic_last_post_time = $lastPost->post_time;
if ($lastPost->user === null) {
$this->topic_last_poster_id = null;
$this->topic_last_poster_name = null;
$this->topic_last_poster_colour = null;
} else {
$this->topic_last_poster_id = $lastPost->user->user_id;
$this->topic_last_poster_name = $lastPost->user->username;
$this->topic_last_poster_colour = $lastPost->user->user_colour;
}
}
}