How to derive the shape functions of a beam resting on an elastic foundation?

Good day community,

I know that for a simple 2D beam, to derive the shape functions I should consider two nodes: one at each end of the beam. Each of the nodes has one displacement and one rotation. The displacement as a function of x is considered to be a polynomial to the third order. Then, by solving for the coefficients of the polynomial, one can easily derive the shape functions.

However, I would like to know how to derive the shape functions for a 2D beam resting on an elastic foundation. Please, how can I modify the displacement in terms of x in order to include the elastic foundation? Also, in case the foundation is nonlinear, how to take that into account in deriving the shape functions?
Your help and directions are highly welcome.

Thank you.

Hley