在null上调用成员函数lists()

When I want to edit a post I'm getting an error. This is the code from the line where the error is:

public function getTagListAttribute()
{
    return $this->tags->lists('id')->all();
}

It works perfectly when I read the full post but when I want to edit it I get thrown this error: Call to a member function lists() on null

I have also categories code:

public function getCategoryListAttribute()
{
    return $this->categories->lists('id')->all();
}

And I can edit fine categories but not tags, and they're made the same principal.