Hi there,
I am having difficulties with integrating datatables. Somehow, my data is being lost/weirdly modified when putting it in my response variable.

foreach($aaData as $aData)
    echo "-".$aData."<br>";
foreach($aaData as $aData)
    $response['aaData'][] = $aData;

My first foreach loop outputs data, and what I see is what I expect.
However, when viewing my data in response, it does not contain the rows of data I expect. It does contain the same number of rows, but only one of my columns, and an additional four fields that I think describe my database table.
In the following, the first is my actual r,ow in database and what I see from my first loop. The second is what my json seems to contain.

-{"id":42,"emri":"Bibiki","mbiemri":"Bibiki","datelindja":"27\/03\/1981","num_personal":"1036","grupi_gjakut":"0","adresa":"","gjinia":"","profesioni":"","telefoni":"","dega":"","nendega":"","statusi_martesor":"0","e_mail":"","data_anetaresimit":"2014-03-12 00:00:00","kombesia":"Shqiptar","admini":1,"vendi_punes":""}

[{"timestamps":false,"gjinia":"Femer","incrementing":true,"exists":true}]

Anyone, please help.
Kind regards

Seems like the issue was a Laravel framework specific one.
I had to invoke the toArray() method on my collection of objects before putting it on my return array.

The proper way to do it is:

public function getMembers(){
    $members = Members:all()->toArray();
    $rez = array();
    $rez['aaData'] = $members;
    return $rez;
}

I'm putting the solution up lest someone needs it in the future.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.