App\Models\Forum\Topic::setFirstPostCache PHP Метод

setFirstPostCache() публичный Метод

public setFirstPostCache ( )
    public function setFirstPostCache()
    {
        $firstPost = $this->posts()->first();
        if ($firstPost === null) {
            $this->topic_first_post_id = null;
            $this->topic_poster = null;
            $this->topic_first_poster_name = null;
            $this->topic_first_poster_colour = null;
        } else {
            $this->topic_first_post_id = $firstPost->post_id;
            if ($firstPost->user === null) {
                $this->topic_poster = null;
                $this->topic_first_poster_name = null;
                $this->topic_first_poster_colour = null;
            } else {
                $this->topic_poster = $firstPost->user->user_id;
                $this->topic_first_poster_name = $firstPost->user->username;
                $this->topic_first_poster_colour = $firstPost->user->user_colour;
            }
        }
    }