phpmysqllaravelredispredis

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);

This throws me "Serialization of 'PDO' is not allowed", if i am trying

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);

then datatables throws error of Method Illuminate\Database\Eloquent\Collection::getQuery does not exist

Anyone have solution for these?


Solution

  • Use ::of() instead of ::eloquent().