Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cshehadi's avatar

Register model to application

This is my first time writing a Laravel application. I am just starting to learn the framework.

My application should handle traffic from several different domain names, detect the domain, lookup appropriate environment information and save that somewhere so that it's available throughout the application.

Example - request comes in for abcde.com/some_page. Before it sends traffic to the somePage controller, it should look up abcde.com in a database table, and then load that row of configuration data somewhere so that it can be read anywhere.

I've figured out how to get the domain name from the request, and use Eloquent to load the configuration data into a model.

So what is the most "Laravel" way to make this model available throughout the application?

Basically I want to be able to do something like call: app()->site (where site is the model) and have access to all model's properties and methods.

Can you point me toward the best way to do this?

Thanks for your help!

0 likes
2 replies
martinbean's avatar

@cshehadi What you’re describing is multi-tenancy. Google it, as there are numerous packages to assist in building multi-tenant applications with Laravel.

Please or to participate in this conversation.