###前提・実現したいこと
Laravel5.4にてRoutes内でサブドメインを判定し、サブドメインごとにview等を分けるシステムを作っています。
config内のconst.phpもサブドメインごとディレクトリを分けていますが、routes内にてサブドメインに対応するconst.phpを参照したく、下記のようなプログラムを組んでいます。
php
1Route::group([ 2 'domain' => '{subdomain}.example.com', 3 'namespace' => 'Customer', 4], function () { 5 Route::get('/{area}', 'Search\TopController@searchArea') 6 ->name('customer.search.area') 7 ->where('area',Config::get($subdomain . '.const.area')[0]); 8});
configのディレクトリ構造は下記の通りです。
config ┗subdomain1 ┗const.php ┗subdomain2 ┗const.php
###実行結果&質問内容
上記を実行したところ、$subdomainが参照できず下記エラーとなってしまいます。
(1/1) ErrorException Undefined variable: subdomain
Laravelにおけるルーティングの書き方をイマイチ理解できておらず、解決方法が分かりません。
$subdomainはどのように取得したら良いでしょうか。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/27 02:35
2017/11/27 08:00
2017/11/27 09:02