Commit 57cf817d authored by Taylor Otwell's avatar Taylor Otwell

Fix pivot constraints on ->pivot() method of many-to-many.

Signed-off-by: 's avatarTaylor Otwell <taylorotwell@gmail.com>
parent 879e56df
......@@ -341,7 +341,11 @@ class Has_Many_And_Belongs_To extends Relationship {
*/
public function pivot()
{
return new Pivot($this->joining);
$key = $this->base->get_key();
$foreign = $this->foreign_key();
return with(new Pivot($this->joining))->where($foreign, '=', $key);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment