I'm creating a plataform to support multiple websites under the plataform, and some websites needs to have a different domain.
The most commom is to use the same domain:
myrootdomain.com/first_product/profile
myrootdomain.com/second_product/profile
In these cases, the {first_product} and {second_product} will be passed as argument to almost all functions. /first_product and /second_product are total different websites running under the same plataform.
But I need to create another product where I can change the TLD and still be able to identify {anotherrootdomain} as the first parameter to my functions. Something like this:
anotherrootdomain.com/profile
I'm already handling the first parameter using Route::bind.
<?php
Route::bind('short_url', function($value, $route)
{
$product = Product::where('short_url', $value)->first();
if(is_null($product))
return false;
return $product->id;
});
Route::get('/{short_url}/login', 'HomeController@login');
Route::get('/{short_url}/profile', 'UserController@profile');
Now I don't know how to:
1) look for domain
2) use the domain as the first parameter
I know my english is terrible, but I hope you can help me!
EDIT:
I can do something like this on routes.php:
if($_SERVER['HTTP_HOST'] == "anotherrootdomain.com")
$tld = "anotherrootdomain";
Then I need to chance from this:
Route::get('/{short_url}/login', 'HomeController@login');
Route::get('/{short_url}/profile', 'UserController@profile');
To this:
Route::get('/login', 'HomeController@login');
Route::get('/profile', 'UserController@profile');
And I can do it using a simple if, but now I can't pass the parameter on my routes! HomeController@login expects a parameter, and I need to pass $tld variable, but I don't know how!