Closed obahareth closed 6 years ago
I have the following classes:
<? class User extends Moloquent { protected $collection = 'users'; public function challengesWon() { return $this->belongsToMany('Challenge', null, 'winning_users', 'challenges_won'); } } class Challenge extends Moloquent { protected $collection = 'challenges'; public function winningUsers() { return $this->belongsToMany('User', null, 'challenges_won ', 'winning_users'); } }
When I try to do:
$challenge->winningUsers()->get();
I get 0 results. I went in and checked the queries that have been run using barryvdh's Laravel Debug Bar and I found that the query being run is this:
users.find({"challenges_won ":"53fd9e0175cde71e158b4567"},[])
The correct query to run would be this:
users.find({"challenges_won":{$in : ["53fd9e0175cde71e158b4567"]}})
did you solved this?
I have the following classes:
When I try to do:
I get 0 results. I went in and checked the queries that have been run using barryvdh's Laravel Debug Bar and I found that the query being run is this:
The correct query to run would be this: