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

3
  • 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.. Commented Mar 17, 2015 at 12:51
  • possible duplicate of Creating default object from empty value in PHP? Commented Mar 17, 2015 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. Commented Mar 17, 2015 at 12:59

1 Answer 1

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));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.