Reputation: 945
I have been trying to change layout dynamically in laravel by just passing a variable in
@extends('default1.master')
to
$var = default2
@extends('$var.master')
possibly
@extends($var.'.master')
tried a lot but unable to find a solution all I get is error in my syntax or view not found.
Upvotes: 8
Views: 4886
Reputation: 6361
in your view you can pass a variable with the view name like
@extends('layout.'.$view)
//or
@extends($view.'.base')
here $view is a variable which stored the view name from controller my controller looks following
$view = 'base';
return view('someview', compact('view'));
and if by any chance you are declaring this $var in the view file only you should not forget to enclose it in
<?php ?> tag
Upvotes: 13