试图获取非对象Laravel的属性用户

I have model review with:

public function shop()
{
    return $this->belongsTo(Shop::class);
}

public function user()
{
    return $this->belongsTo(User::class);
}

public function parent()
{
    return $this->belongsTo(static::class, 'id', 'parent_id');
}

public function isParent()
{
    return !$this->parent_id;
}

public function children()
{
    return $this->hasMany(static::class, 'parent_id');
}

public function sendReviewNotification()
{
    if ($this->isParent()) {
        $this->shop->owner->sendReviewParentNotification($this);
    } else {
        if ($this->user->is($this->parent->user)) {
            $this->shop->owner->sendReviewCommentNotification($this);
        } else {
            $this->parent->user->sendReviewCommentNotification($this);
        }
    }
}

When I add a child comment to a parrent comment I get error: 'Trying to get property 'user' of non-object', in ReviewObserver I call sendReviewNotification like this:

public function created(Review $review)
{
    $review->sendReviewNotification();
}

When I add parent module. Than all working, but when I add a child comment than I get this error. Why parent relation not working?

You should pass the foreign key as the second parameter, not the id:

public function parent()
{
    return $this->belongsTo(Parent::class, 'parent_id');
}

Docs:

Eloquent determines the default foreign key name by examining the name of the relationship method and suffixing the method name with _id. You may pass a custom key name as the second argument to the belongsTo method

For more info: click here