M
M
Maxim Grechushnikov2018-07-05 20:36:16
Laravel
Maxim Grechushnikov, 2018-07-05 20:36:16

How to get all club members' runs?

Available:
Club.php User.php club_users link M:M
Scampers.php (runs) User(id)-Scamper(id,user_id) link 1:M
How do I get all club members' runs?
user relation:

public function scampers()
{
    return $this->belongsToMany(Scamper::class);
}

Club relation:
public function scampers()
{
    return $this->hasManyThrough(Scamper::class, User::class);
}

I understand that the problem is in club.scampers, but I don't know how to do it right.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question