laravel Call to a member function addEagerConstraints() on null

Call to a member function addEagerConstraints() on null

这是laravel的关联关系出问题

原因:你没有返回关联关系,就调用了关联方法

解决:

public function xxx()
    {
        return $this->belongsTo(yyy,'外键');
    }

return 出去没有return  肯定报错

原文地址:https://www.cnblogs.com/zqblog1314/p/12774213.html