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.
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
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