Support the ongoing development of Laravel.io →
Database
Last updated 1 year ago.
0
Solution

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.

Last updated 1 year ago.
0

Hello,

don't you think you need some key or something? maybe $abc->id, or $abc->title or something similar?

Last updated 1 year ago.
0

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.

Last updated 1 year ago.
0

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 }}.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Cloudways

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 Laravel.io - All rights reserved.