我试图在laravel中使用数据表,但得到以下响应:
{
"message": "foreach() argument must be of type array|object, null given",
"exception": "ErrorException",
我已在控制器中尝试此代码:
$dataLists= DB::table("table_name")
->select('column_1', 'column_2')
->get();
return Datatables::of($dataLists)
->make(true);
如果我打印$数据显示器,它会显示以下格式的数据
Illuminate\Support\Collection 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
)
)
)
我的php版本是: 8.0.0和laravel版本是: 8.20.1
有人能帮我找出哪里错了吗?
只需清除laravel的配置缓存php artisan配置:缓存