My question of the day)
I have already implemented subdomains for cities on Laravel, but I ran into a problem!
I apologize for my english)))
I want to:
NewYork was without a subdomain website.ru
California with a subdomain California.website.ru
Texas with a subdomain Texas.website.ru
NewYork == null
I did this:
Database
alias | name
-------------------------
null | NewYork
california | California
texas | Texas
Route
Route::group([
'domain' => '{city_alias}.website.ru',
'namespace' => 'Available',
], function (){
Route::get('/', 'IndexController@index')->name('index');
});
Links in blade
route('category.one', [$city_one->alias, $category_one->alias])
Controller
class IndexController extends Controller
{
public function index($city_alias)
{
$city_one = City::cityAlias($city_alias)->first();
return view('........');
}
}
The problem is with the city of NewYork!
How can I make NewYork without a subdomain?? + less when to write.
I found a function here, maybe it's the case?
Illuminate\Routing\Route.php
/**
* Get or set the domain for the route.
*
* @param string|null $domain
* @return $this|string|null
*/
public function domain($domain = null)
{
if (is_null($domain)) {
return $this->getDomain();
}
$parsed = RouteUri::parse($domain);
$this->action['domain'] = $parsed->uri;
$this->bindingFields = array_merge(
$this->bindingFields, $parsed->bindingFields
);
return $this;
}