Laravel belongsToMany select all specified ids
Relation public function groups() { return $this->belongsToMany('AppModelsItemGroup','item_to_group','item_id','item_group_id'); } ** How to select all Items that have item_group_id 0 and 9 BOTH?** $zero_and_nine_count = AppModelsItem::with(['groups' => function ($query) { $where[] = ['item_group_id', , 0]; $where[] = ['item_group_id', '=', 9]; $query->where($where); }])->count();…