Try to switch {{ $data = DB::table('data')->get() }} this for regular php tags, I would say that you are trying to echo result of that db query.
Hello,
don't you think you need some key or something? maybe $abc->id, or $abc->title or something similar?
Joe5: Then I'm getting error "Object of class stdClass could not be converted to string "
Edit:
dakshhmehta: Yes, now it works
Thank you both very! It have to be with php tags and after that with that key.
The {{ ... }}
is for echoing a variable, not for assigning something.
You can put the DB::table('data')->get()
in your foreach. However, preferably, you should pass this data to your view from the controller. That means moving the assigning line (the one you have already put in {{ ... }}
) to your controller instead, and just looping through the results in your view. For example:
$data = DB::table('data')->get();
return View::make('abc.table', array('data' => $data));
Also, inside your foreach, you are trying to echo a whole object. You need to echo a property (I.E. a column from your database table). For example, put in {{ $abc->id }}
.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community