Which APOC used to handle Match and merge for multiple conditional statements

I have a requirement to read and write data based on multiple conditions for node. for example

if p.all_friends="Y" then "match (f:Employee)-[rel:FRIEND_WITH]-(e)" then "MERGE (p)<-[:CREATED_POST]-(f)
if p.all_colleagues="Y" then "match(e)-[rel:REPORTS_TO]->(SUPERVISOR:Employee) then Merge(colleagues_-[:CREATED_POST]->(p)

likewise i have n number of conditions for both match and merge.
Can you please suggest here which APOC will help here to handle this.
Also we can use Foreach but that will not support for match clause i think.

Thank you

Hi Michael,

Can you please advise here for the mentioned use case.
Thanks in advance.