Question about と聞(き)く

Can I say both? 明日は家族と旅行に行くと聞きました。 And 明日は家族と旅行に行くことを聞きました Are they both grammatically correct? And if so, do they have…