Q:

Laravel Route to multi domain

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!

A:

I realized a way to do it!
Let's say that my /second_product on the example needs to be accesible using another TLD, like "awesomeproduct.com". Some URLs need to chance:
myrootdomain.com/second_product/login => awesomeproduct.com/login
myrootdomain.com/second_product/profile => awesomeproduct.com/profile
While the first_product still just working the first way:
myrootdomain.com/first_product/login
myrootdomain.com/first_product/profile
To make it possible, I created a route group with sub-domain (I didn't know that I could also use wildcard on TLD):
Route::group(array('domain' => '{short_url}.com'), function($short_url)

And I changed a little bit my Route::bind to change the {short_url} parameter:
Route::bind('short_url', function($value, $route)
{
    if($value == "awesomeproduct")
        $value = "second_product";

    $product = Product::where('short_url', $value)->first();

    if(is_null($product))
        return false;
    return $product->id;
});

Finally, I need to change my routes to use or not the {short_url}:
$tld = "";
if($_SERVER['HTTP_HOST'] != "testefacop.com")
    $tld = "{short_url}/";

Route::get('/'.$tld.'login', 'HomeController@login');
Route::get('/'.$tld.'profile', 'UserController@profile');

And here is my complete routes.php:
<?php

Route::bind('short_url', function($value, $route)
{
    if($value == "awesomeproduct")
        $value = "second_product";

    $product = Product::where('short_url', $value)->first();

    if(is_null($product))
        return false;
    return $product->id;
});

Route::group(array('domain' => '{short_url}.com'), function($short_url)
{
    $tld = "";
    if($_SERVER['HTTP_HOST'] != "awesomeproduct.com")
        $tld = "{short_url}/";

    Route::get('/'.$tld.'login', 'HomeController@login');
    Route::get('/'.$tld.'profile', 'UserController@profile');

}

It isn't a great and beatifull solution, but it's working as expected!

