不允许 'PDO' 的序列化 - Laravel 使用 Datatable 进行缓存

Serialization of 'PDO' is not allowed - Laravel caching with Datatable

if (!Cache::store('file')->has('channel')) {
        $products = Channel::select('*');
        Cache::store('redis')->put('channel', $products, 86400);
}
$products = Cache::store('redis')->get('channel', []);

return DataTables::eloquent($products)
      ->addIndexColumn()
      ->make(true);

如果我正在尝试

,这会抛出“不允许 'PDO' 的序列化”
if (!Cache::store('file')->has('channel')) {
        $products = Channel::select('*')->get();
        Cache::store('redis')->put('channel', $products, 86400);
}
$products = Cache::store('redis')->get('channel', []);

return DataTables::eloquent($products)
      ->addIndexColumn()
      ->make(true);

然后 datatables 抛出方法 Illuminate\Database\Eloquent\Collection::getQuery 不存在的错误

有没有人解决这些问题?

使用 ::of() 代替 ::eloquent()