Turn to face the wall that the beam is pushing you into and put a portal here so you’re taken through and across the chasm.
Once you hit the wall, look directly down at the chequered floor panel and place your exit portal here, the beam will carry you up to the top platform.
Look back over the left-hand ledge and the Cube will be stuck against the wall. Fire your exit portal down here (step out of the beam if it catches you) and then wait for the Cube to rise up. Pick it up and set it down on the chequered floor panel up here.
Get your exit portal on this floor panel and it’ll carry the Cube up to the switch on the ceiling, raising the platforms to the exit to your left.