I have a little problem with laravel that can be easily solved. In short, the situation is this: I have two tables, one for users, and the other for products with a "user_id" column, so I can identify the associated user.
In Laravel I can use
$user = Sentry::getUser();
$products = DB::table('table2')->where('user_id',$user->id);
And that should give me every product the user has. Good.
Now I want to show products individually on the screen, but unfortunately this does not work. It seems that I cannot repeat this information in a row, because it consists of several lines. I get
Object of class Illuminate\Database\Query\Builder could not be converted to string
For the solution, since the maximum associated products that I allowed in the system are 3, I came up with the idea to split each line and repeat them. For the first, this is simple: $products->first();but I have no idea how to get the other two.
And maybe I'm new here, but I don’t think I can use product identification information since $ products-> id returns an error.
Can anybody help me?
Thanks in advance!
source
share