If you want to get the root URL in your model, then I made an ENV variable call.
If you have not already done so, go ahead and create .env in the root directory of your application and install in development:
ROOT_URL=http://localhost
In your work environment:
ROOT_URL=https://mydomain.com
Of course, this is hard-coded, so the error is that you need to remember to change this when changing domains, and each environment file should be different.
And make sure this is also in your gitignore, as other important data is stored here.
In your model, you call: ENV ['ROOT_URL']
source share