Recent elaborated by T. Harko and collaborators, the $f(R,T)$ theories of gravity contemplate an optimistic alternative to dark energy, for which $R$ and $T$ stand for the Ricci scalar and the trace of the energy-momentum tensor, respectively. Although the literature has shown that the $T$ dependence on the gravitational part of the action - which is due to the consideration of quantum effects - may induce some novel features in the scope of late-time cosmological dynamics, in the radiation-dominated universe, when $T=0$, no contributions seem to rise from such theories. Apparently, $f(R,T)$ contributions to a radiation-dominated universe may rise only from the $f(R,T^varphi)$ approach, which is nothing but the $f(R,T)$ gravity in the case of a self-interacting scalar field whose trace of the energy-momentum tensor is $T^varphi$. We intend, in this article, to show how $f(R,T^varphi)$ theories of gravity can contribute to the study of the primordial stages of the universe. Our results predict a graceful exit from inflationary stage to a radiation-dominated era. They also predict a late-time cosmic acceleration after a matter-dominated phase, making the $f(R,T^varphi)$ theories able to describe, in a self-consistent way, all the different stages of the universe dynamics.