Answer the question
In order to leave comments, you need to log in
Many-to-many relationships, get data not related to relationship?
There is such a connection in the database.
Connected them through belongsToMany.
I get the result $products = User::find(Auth::id())->products()->get();
Actually, is it possible to modify this query to have the "count" property from the link table? To get it like this:
foreach ($products as $product)
$product->name //product name (works)
$product->price //price (works out)
$product->count //quantity in a basket (somehow it is necessary to receive)
PS Or the linking table should not have additional. properties and you need to remove the "count" column, make a separate table with the "count" column and link it one-to-one with the connecting users and products?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question