Problems with Laravel's relationship hasmany in search bar
Problems with Laravel's relationship hasmany in search bar
Hello!
I've been trying to find a way to a way to pass a Laravel's relationship data into the Datatables' columns.
What I'm doing is passing all the emails from the users who has a record in that table (hasMany).
Since some users have more than one email, from those what I receive from the relationship is an array.
I can receive the data and display it on the table, but I cannot make it searchable (all the emails) in a way that doesn't trigger an error (DataTables warning: table id=data_table - Ajax error and an eternal loading).
From another topics, what I got was setting something similar to:
JS:
{
data: 'emails.0.email',
name: 'emails.email',
className: "collapse",
render: function(data, type, full, meta) {
return data;
}
}
Thanks in advance.
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
Answers
You shouldn't need the
columns.render, but otherwise it looks fine. Could you post the Ajax for a record, please.Colin