I have a query from Database which is John and Mary under display_name. For (ID 1 = John)(ID 2 = Mary) I have a data on view that contain two values or ID in one cell using AJAX Datatable based on this picture.
How can I seperate or make a space between this two values that bring ID on view Datatables ? I want to make "John Mary" instead of "JohnMary" in one cell column.
Here is my Index datatable code:
->addColumn('roles', function($record){
$data='';
if($record->role()->get()){
foreach ($record->role()->get() as $role){
$data .= $role->display_name;
}
}
return $data;
})
Adding a space after your name will do the trick:
$data .= $role->display_name . ' ';