At first you cannot use 2 return like this
public function Messages()
{
return $this->hasMany('App\Models\Messages', 'from', 'id');
return $this->hasMany('App\Models\Messages', 'to', 'id');
}
It is better if you divide it into 2 methods as follows:
public function to()
{
return $this->hasMany('App\Models\Messages', 'to', 'id');
}
public function from()
{
return $this->hasMany('App\Models\Messages', 'from', 'id');
}
source
share