Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Response is casting all attributes to string #1975

Closed
D4ni3lr opened this issue Jan 30, 2019 · 7 comments
Closed

Response is casting all attributes to string #1975

D4ni3lr opened this issue Jan 30, 2019 · 7 comments

Comments

@D4ni3lr
Copy link

D4ni3lr commented Jan 30, 2019

Al attributes are being casts as String

All attributes are being casts to String, even when the $casts attribute is present in the model.

I've tried with

Datatables::of(Model::get())->toJson();
Datatables::of(Model::get())->make();
datatables()->of(Model::get())->toJson();
datatables()->of(Model::get())->make();

Same result.

When i return Model::get(); or Model::all(); the attribute types are returned as expected.

System Details

  • Windows 10
  • Apache 2.4
  • PHP 7.1
  • laravel/framework v5.5.45
  • yajra/laravel-datatables v1.4.0 Laravel DataTables Complete Package.
  • yajra/laravel-datatables-buttons v4.5.0 Laravel DataTables Buttons Plugin.
  • yajra/laravel-datatables-editor v1.6.1 Laravel DataTables Editor plugin for Laravel 5.5+.
  • yajra/laravel-datatables-fractal v1.3.0 Laravel DataTables Fractal Plugin.
  • yajra/laravel-datatables-html v4.3.1 Laravel DataTables HTML builder plugin for Laravel 5.4+.
  • yajra/laravel-datatables-oracle v8.13.4 jQuery DataTables API for Laravel 4|5
@D4ni3lr
Copy link
Author

D4ni3lr commented Jan 30, 2019

Hi, the problem was introduced in this PR: #1952 in file DataProcessor.php inside the function escapeRow two lines where removed.

// File: src/Processors/DataProcessor.php
...
if (! in_array($key, $this->rawColumns)) {
       $dataType       = gettype($value); 
       $arrayDot[$key] = e($value);
       settype($arrayDot[$key], $dataType);
 }
...

@yajra
Copy link
Owner

yajra commented Feb 5, 2019

It was a recent PR #1942 that fix the casting issue, however it broke #1951. Need to review this again further and waiting for feedbacks from the other guys @ridaamirini @aurelijussaldauskas.

@Thijmen
Copy link

Thijmen commented Mar 22, 2019

Really waiting for this one, any updates?

@artemsky
Copy link

any update?

@bendt-indonesia
Copy link

Same problem here, using PHP 7.2, Laravel 5.8, yajra/laravel-datatables-oracle 9.4.0

@bendt-indonesia
Copy link

Hi, the problem was introduced in this PR: #1952 in file DataProcessor.php inside the function escapeRow two lines where removed.

// File: src/Processors/DataProcessor.php
...
if (! in_array($key, $this->rawColumns)) {
       $dataType       = gettype($value); 
       $arrayDot[$key] = e($value);
       settype($arrayDot[$key], $dataType);
 }
...

This works, if i added the two rows back

@fayaz668
Copy link

Really waiting to fixe this issues, any updates?

@yajra yajra closed this as completed May 30, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Oct 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants