  We study the influence of photons on the dynamics and the ground state of the
atoms in a Bosonic Josephson junction inside an optical resonator. The system
is engineered in such a way that the atomic tunneling can be tuned by changing
the number of photons in the cavity. In this setup the cavity photons are a new
means of control, which can be utilized both in inducing self-trapping
solutions and in driving the crossover of the ground state from an atomic
coherent state to a Schr\"odinger's cat state. This is achieved, for suitable
setup configurations, with interatomic interactions weaker than those required
in the absence of cavity. This is corroborated by the study of the entanglement
entropy. In the presence of a laser, this quantum indicator attains its maximum
value (which marks the formation of the cat-like state and, at a semiclassical
level, the onset of self-trapping) for attractions smaller than those of the
bare junction.
