this is my query
$recetas = Recetas::whereHas('categorias', function ($query) {
$query->where('nombre', 'Comida alta en Grasas')
;
})->paginate(5);
A recipe can match several categories, so I need to be able to add where, but I add them and they don't print anything, does anyone know how I can add conditions to this query?
Use the method
whereIn
that will search for the column to have any of the values that you pass in the array as a value:In this way we would be telling the query: Bring the lines that have categories whose names are contained within the values of the passed array.