I am trying to use data tables in laravel but getting below response:
{
"message": "foreach() argument must be of type array|object, null given",
"exception": "ErrorException",
I have tried this code in my controller:
$dataLists= DB::table("table_name")
->select('column_1', 'column_2')
->get();
return Datatables::of($dataLists)
->make(true);
If I print $datalists it display data in below formate
IlluminateSupportCollection Object
(
[items:protected] => Array
(
[0] => stdClass Object
(
[column_1] => 386932
[column_2] => data name 1
)
[1] => stdClass Object
(
[column_1] => 8764358
[column_2] => data name 2
)
)
)
My php version is: 8.0.0
and laravel version is: 8.20.1
Can someone please help me to find out Where I am wrong?
question from:
https://stackoverflow.com/questions/65878089/foreach-argument-must-be-of-type-arrayobject-null-given-exception-errore 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…