Answers for "call to a member function addeagerconstraints() on null i"

7

Call to a member function addEagerConstraints() on null

You are missing return statements in the methods that define relations. They need to return relation definition.
Posted by: Guest on September-25-2020
0

Error: Call to a member function addEagerConstraints() on null in file

in your relationship you are missing return statement, 
please follow the following example

public function user() {
        $this->belongsTo(User::class,'user_id','id');
}

to 
  
public function user() {
        return $this->belongsTo(User::class,'user_id','id');
    }
Posted by: Guest on January-04-2022

Code answers related to "call to a member function addeagerconstraints() on null i"

Browse Popular Code Answers by Language