Reputation: 1333
In my Laravel-5.8 project, I am trying to myconfig.php inside app/config. I want it to return this array
return ['default_domain_name' => 'myapp']
as in: app/config/myconfig.php
I want to call it inside the middleware I created
class VerifyDomain
{
public function handle($request, Closure $next)
{
$request->get('domain_name', $this->getBaseDomain());
$company = Company::where('subdomain', $subdomain)->firstOrFail();
$request->session()->put('subdomain', $company);
return $next($request);
}
protected function getBaseDomain()
{
return config('myconfig.default_domain_name', 'myapp');
}
}
How do I write to return:
return ['default_domain_name' => 'myapp']
inside app/config/myconfig.php
Thanks
Upvotes: 1
Views: 1678
Reputation: 784
If your config looks like this:
return [
'default_domain_name' => 'myapp',
]
... and your config file has myconfig.php
name...
Just call
config('myconfig'); // returns ['default_domain_name' => 'myapp']
Upvotes: 1