How to loop over (JSON) array in Slim

Thanks llvdl,

I am getting there… :wink:

$data can contains multiple Array’s. I tried:

$queryBuilder = Product::where('active', true);
foreach ($activity as $item)
{
$queryBuilder->where(function($query) use ($item)
{
if(count($item) > 1
{
foreach ($item as $key)
{
$query->orWhere('activity', $key)
}
} else {
$query->orWhere('activity', $item)
}
});
}

result = (more or less):
select * from 'products' where 'active'= ? and ('activity' =?) and ('activity' = ? )

If i change the ‘where’ clausule in the first foreacht loop:
$queryBuilder->where(function($query) use ($item)

result = (more or less):
select * from 'products' where 'active'= ? or ('activity' =?) or ('activity' = ? )

I would like to make the result:
`select * from ‘products’ where ‘active’= true and (‘activity’ = ? or ? or ? or ? or ?) and (‘country’ = ? or ?)

Perhaps I have to use ->whereIn or something else?

P.s. how can I make the code formatting the same as your post?