App\Models\Forum\Forum::getForumParentsAttribute PHP Method

getForumParentsAttribute() public method

This method isn't intended to be directly called but through Laravel's attribute accessor method (in this case, $forum->forum_parents) warning: don't access this attribute (forum_parents) without selecting parent_id otherwise returned value may be wrong.
public getForumParentsAttribute ( string $value ) : array
$value string
return array
    public function getForumParentsAttribute($value)
    {
        if ($this->parent_id === 0) {
            return [];
        }
        if (presence($value) === null && $this->parentForum !== null) {
            $parentsArray = $this->parentForum->forum_parents;
            $parentsArray[$this->parentForum->forum_id] = [$this->parentForum->forum_name, $this->parentForum->forum_type];
            $this->update(['forum_parents' => $parentsArray]);
            return $parentsArray;
        } else {
            return unserialize($value);
        }
    }