Search code examples
phplaravel-5eloquentyajra-datatable

Eloquent DataTables casts all attributes to string


Eloquent DataTables casts all attributes to a string, even int ids.

PHP 7.2

Laravel Version 5.5

Yajra laravel-datatables Version 8.4

Mysql 8

Code snippet of problem

return \DataTables::eloquent(Users::where('isActive',1))
        ->make(true);

Solution

  • this is work for me

     return \DataTables::eloquent(Users::where('isActive',1))
            ->rawColumns(['id'])
            ->make(true);
    

    added ->rawColumns(['id']) before ->make(true);