在 null 上调用成员函数 addEagerConstraints() 在 laravel 6 上出现此错误
Call to a member function addEagerConstraints() on null getting this error on laravel 6
我正在使用 laravel 6.0,我收到了这个奇怪的错误 "Call to a member function addEagerConstraints() on null" 我有的是通知 table 我有 notification_id 和这个 notification_id 链接到 notification_message table,我试图在它们之间创建一个关系我尝试了一切,但我收到了这个奇怪的错误。
这是我定义此关系的通知模型
public function notificationMessage(){
$this->hasOne('App\Models\NotificationMessage','id');
}
别忘了return
关系
public function notificationMessage(){
return $this->hasOne('App\Models\NotificationMessage','id');
}
我正在使用 laravel 6.0,我收到了这个奇怪的错误 "Call to a member function addEagerConstraints() on null" 我有的是通知 table 我有 notification_id 和这个 notification_id 链接到 notification_message table,我试图在它们之间创建一个关系我尝试了一切,但我收到了这个奇怪的错误。
这是我定义此关系的通知模型
public function notificationMessage(){
$this->hasOne('App\Models\NotificationMessage','id');
}
别忘了return
关系
public function notificationMessage(){
return $this->hasOne('App\Models\NotificationMessage','id');
}