title: How can I change Layout in Controller's Method (Laravel)
body: <p>I used multiple layouts in Laravel using code as below, it works.</p>
  
  <pre><code>class UsersController extends BaseController {
  
      public $layout = 'layouts.default';
  
      ...
  }
  </code></pre>
  
  <p>But now I want to change the layout in Method (In UsersController)</p>
  
  <pre><code>public function myFunc(){
  
      //I want to change myFunc's layout to 'default2'
  
      $this-&gt;layout-&gt;content = View::make('user.myfunc');
  }
  </code></pre>
  
  <p>How can I do? Because when I use <code>$this-&gt;layout = 'layouts.default2'</code></p>
  
  <p>it always returns me <code>ErrorException: Attempt to assign property of non-object</code></p>