I have two arrays - $products and $userProducts (this has to be done with two queries since I am searching for products based on the name, and there is another table where I store products which user wants to sell, and I want to show to the user that he already put this product for sale).
$products array looks like this:
[
'id' => 1,
'name' => 'product name',
'synonim' => 'synonim'...
],
[
'id' => 2,
'name' => 'product name 2',
'synonim' => 'synonim'...
]....
and $userProducts looks like this:
[
'product_id' => 1
],
[
'product_id' => 75
]
I want to add attribute to the $products array (or if there is a better way to do this, that can also work) 'userHasProduct' => true, if $userProducts contains product_id which mathces with id from $products id. How can I make this work?