I was able to achieve this using special middleware. In my case, I had to display another template / theme based on the domain name.
TemplateMiddleware.php
public function handle($request, Closure $next)
{
$paths = [];
$app = app();
$template = Template::where('domain', Request::server('SERVER_NAME'))->first();
if($template)
{
$paths = [
$app['config']['view.paths.templates'] . DIRECTORY_SEPARATOR . $template->tag
];
}
$paths[] = $app['config']['view.paths.default'];
$finder = new FileViewFinder(app()['files'], $paths);
View::setFinder($finder);
return $next($request);
}
Kernel.php
protected $middleware = [
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
\App\Http\Middleware\TemplateMiddleware::class,
];
source
share