Doesn't Laravel eloquent hasmany allow multiple columns?

Viewed 22
return $this->hasMany(Key::class, 'order_id' , 'order_id')->with('supplier');

How can I add a 2nd condition here, both order_id must be equal to order_id and game_id must be equal to game_id.

1 Answers

I think you can use this way to have multiple conditions

public function whatever()
{
    return Whatever::where(function ($query) {
        return $query->where('order_id', $this->order_id)
                     ->where('game_id', $this->game_id);
    });
}
Related