Call to a member function comments() on null when use foreign key
This is error Call to a member function comments() on null, in model give a relation still show this error Article model function user() { return $this->belongsTo(User::class, ‘id’); } public function comments() { return $this->hasMany(Comment::class, ‘id’); } Comment Model public function user() { return $this->belongsTo(User::class); } public function article() { return $this->belongsTo(‘App\Article’); } This is… Read More Call to a member function comments() on null when use foreign key