I want to set up multi domains in my laravel 5.1.
I have 3 different domains
www.domain1.com
www.domain2.com
www.domain3.com
every domain will have some common functionality and some different functionality but with different themes
i want my view structure like that
resource/www.domain1.com
resource/www.domain2.com
resource/www.domain3.com
i am unable to separate views how can i achieve this?
**
You should create middle ware to modify path to view folder:
namespace App\Http\Middleware;
use Closure;
use Illuminate\View\FileViewFinder;
use Illuminate\Support\Facades\View;
class ModifyViewFolder
{
public function handle($request, Closure $next)
{
$finder = new FileViewFinder(app()['files'], [
app_path('../resources/views/' . $request->server->get('HTTP_HOST')),
app_path('../resources/views/'),
]);
View::setFinder($finder);
return $next($request);
}
}
Then register it in Your Kernel.php. This will fallback to default folder if view in domain specific folder does not exists.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With