I'm building a multi-site project, each site with different domain, for example "site-two.com", "site-one.net".
I have been searching, but it's not clear for me how to do it, also if it's possible to do it?
I found this example on Laracasts, but I don't understand it:
// routes.php
Route::group(['domain' => '{projectSlug}.{tld}'], function($projectSlug)
{
// Website routes
});
// bindings.php
Route::bind('projectSlug', function($value, $route)
{
return Project::where('slug', '=', $value)->firstOrFail();
});
Route::bind('tld', function($value, $route)
{
$project = $route->getParameter('projectSlug');
if($project->tld !== $value)
App::abort(404);
return $value;
});
// When creating a URL to a route
route('project/home', [$project->slug, $project->tld]);
I also found something simpler on reddit, but I would like to know if this is totally functional, I mean when the domain X is in the browser I'll only have access to the group routes?
Route::group(array('domain' => 'site-one.com'), function() {
/* routes here */
Route::get('/{link_slug}', 'Controller@something');
});
Route::group(array('domain' => 'site-two.com'), function() {
/* routes here */
Route::get('/{link_slug}', 'Controller@something');
});
What could be a great approach of the file structure when having a multi-site project?, a site folder under controller, model, views ... ?