How to display Many-To-Many relationship. #2552
Unanswered
sys-auditing
asked this question in
Q&A
Replies: 1 comment
-
You can use editColumn or addColumn then use the computed key as data for the multiple values. Or you can also use the column renderer if you prefer js. // PHP
->addColumns('contacts_accounts', function($user) {
return $user->contacts->implode('account_number', ', ');
})
// JS
{data: 'contacts_accounts', name: 'contacts[].account_number'}, |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary of problem or feature request
Hi,
i have Many-To-Many relationship between users & contacts table, so i would like to retrieve nested data for a logged in user (
$request->user('api')->id
).As you know, this eager method
with(['contacts.complaints'
returns a collection, that why i have this figure.You can see here, this user is linked to 2 contacts, but are displayed in one row, i need that each result display in separate row.
So how can i loop over
contacts.complaints
and apply$q->with(['comments.user', 'comments.replies.user'])
in order to display for each contact a correspondant complaints, comments ... in row.Any help would be greatly appreciated
Code snippet of problem
System details
Beta Was this translation helpful? Give feedback.
All reactions