If using Eloquent this should work: Tag belongsToMany('Item') Item belongsToMany('Tag')
Item::whereHas('Tag', function($q) use ($ID) {
foreach($ID as $ids) {
$q->where('id', $ID);
}
})->lists('id');
Otherwise maybe try:
$res = DB::table('item_tag');
foreach($ID as $uID){
$res->where('tag_id', '=', $uID);
}
$ItemID = $res->lists('item_id');
allmyitjason said:
Otherwise maybe try:
$res = DB::table('item_tag'); foreach($ID as $uID){ $res->where('tag_id', '=', $uID); } $ItemID = $res->lists('item_id');
I think it's the same as which wont work.
$itemID = DB::table('item_tag')
->where(function($query) use($ID)
{
foreach($ID as $uID){
$query->where('tag_id', '=', $uID);
}
})->lists('item_id');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community