I have a user model
, which can have many reports, and a report model obviously belonging to a user, whenever one is created.
However when I use return $this->belongsTo('App\User')
on the report model
No user is returned even when I have the correct user_id
on the report, and correct id on the user table.
User
protected $fillable = [
'name', 'email', 'password',
];
public function reports()
{
return $this->hasMany('App\Report');
}
Report
protected $fillable = [
'user_id', 'title', 'detail',
];
public function user()
{
return $this->belongsTo('App\User', 'user_id');
}