I have a table called recipes
that has a field cast to an array that houses ids from another table ingredients
. A user can select from a form, specific ingredients they want to see recipes for.
Is there a way I can take the submitted list of ids and only pull recipes that have some of those ids? I say some because I don't want to limit to recipes that have only ALL of the ids. Meaning if someone chooses chicken, onions, and celery and there are recipes that contain those ingredients plus carrots, peppers and mushrooms I want to show those as well.
The only query I can come up with seems to compare exact to exact.
$recipes = Recipes::whereIn('ingredient_ids', $request->ingredient_ids)->get();
With ingredient_ids
being the list of submitted ingredients.