I would setup multiple environments and databases and switch per domain.
That is the safest option but can be a little tricky.
you can setup your environments in bootstrap/start.php
and then create a new database file per domain in app/config/<yourenv>/database.php
I was hoping to have all domains within one database and keep it as simple as possible.
I have the multiple domains working fine and I can load my views per domain without any issues, I guess my problem are my queries.
alexhackney said:
I was hoping to have all domains within one database and keep it as simple as possible.
I have the multiple domains working fine and I can load my views per domain without any issues, I guess my problem are my queries.
in that case you can make a Post Repository and use that throughout your app instead of your Post model
I'm watching this now I'm assuming its what your talking about: https://laracasts.com/lessons/repositories-simplified
well normally you have something like
Post::find(1);
a repository is another class that looks like
class PostRepository {
public static function find($id)
{
return Post::where('domain', '=', Session::get('domain'))->where('id', '=', $id)->first();
}
}
so when you want to get the correct post for a specific domain you can do
PostRepository::find(1);
make sure you set the domain id in the Session
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community