Reputation: 915
I used multiple layouts in Laravel using code as below, it works.
class UsersController extends BaseController {
public $layout = 'layouts.default';
...
}
But now I want to change the layout in Method (In UsersController)
public function myFunc(){
//I want to change myFunc's layout to 'default2'
$this->layout->content = View::make('user.myfunc');
}
How can I do? Because when I use $this->layout = 'layouts.default2'
it always returns me ErrorException: Attempt to assign property of non-object
Upvotes: 1
Views: 5238
Reputation: 6746
You can use this in your controller method :
public function myFunc(){
$this->layout = View::make('layouts.default2');
$this->layout->content = View::make('user.myfunc');
}
Upvotes: 5