Your code doesn't have any unnecessary commas. However, if you want to select only specific columns (e.g., 'fname' and 'lname', not 'mname'), you can remove 'mname' from the array. The modified code would look like this:
fn($record)=>Employee::select(['fname','lname'])->where('id',$record->id)->first()->toArray();
If you are referring to the commas in the output of the toArray() method, these commas are used to separate items in the array. If you want to display the result as a string without commas, you may use the implode() function in PHP.
fn($record)=>{
$employee = Employee::select(['fname','lname','mname'])->where('id',$record->id)->first()->toArray();
return implode(" ", $employee);
}
This will return a string with the values separated by a space.