Laravel - 2xHasMany Relations one other Table

Viewed 51

I have table Messages

with columns from and to

That corresponds to some users in table Users.

So I need something like (hasMany relationship in Users model - hasMany messages)

public function Messages()
    {
        return $this->hasMany('App\Models\Messages', 'from', 'id');
        return $this->hasMany('App\Models\Messages', 'to', 'id');
    }

But there are two returns, and the second one is an Unreachable statement. So how to manage many relations when there is more many than one?

2 Answers
Related