0

I have encountered the following error when I try and run my code

Creating default object from empty value

the line of code in question is :

   $this->layout->content = View::make('search', array('table' => $table));

I am following a tutorial located here : http://wern-ancheta.com/blog/2014/08/10/using-datatables-with-laravel/

any help would be greatly appreciated

Richard Hewitt
  • 345
  • 1
  • 5
  • 22
  • 2
    I'd imagine you're following the tutorial too literally. `$this` can only be used the context of a class. If you're not sure what that means, this tutorial might be slightly above your current level.. – Dan Smith Mar 17 '15 at 12:51
  • possible duplicate of [Creating default object from empty value in PHP?](http://stackoverflow.com/questions/8900701/creating-default-object-from-empty-value-in-php) – mvbrakel Mar 17 '15 at 12:56
  • You shall declare your layout first in controller. You should set the value of ```protected $layout``` to the name of view you want to set as layout for this controller i.e. ```protected $layout = 'layouts.master';``` then it will get resolved to actual view when the controller gets instantiated. – Maksym Mar 17 '15 at 12:59

1 Answers1

1

You don't have layout defined, declare it:

protected $layout = 'layout.default'; 

and then use

$this->layout->content = View::make('search', array('table' => $table));

Or another way:

$layout = new stdClass();
$layout->layout = new stdClass();

$layout->layout->content = View::make('search', array('table' => $table));
cch
  • 3,336
  • 8
  • 33
  • 61