Are you talking about this code?
That is intended to be used on an archive page, because it’s iterating over $wp_query->posts. The example I gave was for an archive because your initial question specifically called out archives as the problem area. It wasn’t really intended to be copied and pasted anyway; I was just trying to illustrated how the principle operated so you could write your own code.
If you’re having trouble getting data from your controller to your blades, then I’d recommending trying to debug where in that pipeline the problem is happening. There are a lot of ways to do that, but I usually just start where var_dumping stuff at different stages to see where the data changes or goes away. For instance, if you var_dump and die in your controller, can you access the data you want? If that spits out data, put the result of your array_map into a variable, then var_dump and die that. Keep doing that all the way down the line, and eventually you’ll figure out where the problem is.