简体   繁体   English

在 null 上调用成员函数 addEagerConstraints() 在 laravel 6 上出现此错误

[英]Call to a member function addEagerConstraints() on null getting this error on laravel 6

I am using laravel 6.0 and I am getting this strange error "Call to a member function addEagerConstraints() on null" what I have is notification table where I am having notification_id and this notification_id is linked to notification_message table, I am trying to create a realtion between them I tried everything but I am getting this strange error.我正在使用 laravel 6.0 并且我收到这个奇怪的错误“调用成员函数 addEagerConstraints() on null”我拥有的是通知表,其中我有 notification_id 并且这个 notification_id 链接到 notification_message 表,我正在尝试创建一个他们之间的关系我尝试了一切,但我收到了这个奇怪的错误。

Here is my notification Model where i have defined this relationship这是我的通知模型,我在其中定义了这种关系

public function notificationMessage(){
    $this->hasOne('App\Models\NotificationMessage','id');
}

Don't forget to return the relationship别忘了return关系

public function notificationMessage(){
    return $this->hasOne('App\Models\NotificationMessage','id');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel 5 查询关系导致“调用成员函数 addEagerConstraints() on null”错误 - Laravel 5 Querying with relations causes "Call to a member function addEagerConstraints() on null" error 在 null 上调用成员 function addEagerConstraints() - Call to a member function addEagerConstraints() on null 在字符串上调用成员函数 addEagerConstraints() - Laravel 8 - Call to a member function addEagerConstraints() on string - Laravel 8 在float LARAVEL上调用成员函数addEagerConstraints() - Call to a member function addEagerConstraints() on float LARAVEL Laravel在布尔值上调用成员函数addEagerConstraints() - Laravel call to a member function addEagerConstraints() on boolean Laravel-在字符串上调用成员函数addEagerConstraints() - Laravel - Call to a member function addEagerConstraints() on string Laravel 调用成员 function addEagerConstraints() on float - Laravel call to a member function addEagerConstraints() on float 由于条件关系,在 null 上调用成员函数 addEagerConstraints() - Call to a member function addEagerConstraints() on null because of a conditional relationship 在字符串上调用成员函数 addEagerConstraints() - Call to a member function addEagerConstraints() on string 我在 integer 上收到对成员 function addEagerConstraints() 的错误调用 - I get The Error Call to a member function addEagerConstraints() on integer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM