laravel Call to a member function addEagerConstraints() on null

Posted 养猪至富

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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  肯定报错

 

以上是关于laravel Call to a member function addEagerConstraints() on null的主要内容,如果未能解决你的问题,请参考以下文章

织梦Fatal error: Call to a member function GetInnerText()

Call to a member function display() on a non-object问题的解决

php 遇到报错 Call to a member function fetch_object()

Call to a member function free_result() on a non-object

关于“Call to a member function display() on a non-object”的解决方案

Fatal error: Call to a member function assign() on a non-object