-
-
Notifications
You must be signed in to change notification settings - Fork 859
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
Eloquent DataTables casts all attributes to string #1747
Comments
Found the related issue/pr: yajra/laravel-datatables-buttons#67. ATM, I think you need to use fractal integration for proper API response but I also agree that we can improve the package not to casts all data to string and let the eloquent casting handle it. Can't check this further though but will definitely implement this when I got the chance. If any of you can, please do not hesitate to submit a PR. Thanks! |
@yajra I added a PR |
Fixed on v8.13.2, thanks to @ridaamirini! |
Revert "[8.0] Keep casted attributes #1747"
What have happened with that? It seems it has been reverted in version 9! protected function escapeColumns(array $output)
{
return array_map(function ($row) {
if ($this->escapeColumns == '*') {
$row = $this->escapeRow($row);
} elseif (is_array($this->escapeColumns)) {
$columns = array_diff($this->escapeColumns, $this->rawColumns);
foreach ($columns as $key) {
Arr::set($row, $key, e(Arr::get($row, $key)));
}
}
return $row;
}, $output);
}
` |
It was reverted due to a breaking change and still unresolved. #1951. Will try to have a look at this again when I got the chance. |
Any updates? |
any updates?? |
@rilwanmsm @fayaz668 I don't think this will be fixed... |
Can't check this further atm. Maybe you guys can provide some tests / feedbacks on #1951? |
@yajra , @ridaamirini below methods works for me
|
Eloquent DataTables casts all attributes to string
Eloquent DataTables casts all attributes to string, even int ids, even if explicit eloquent model $casts is set.
Code snippet of problem
System details
The text was updated successfully, but these errors were encountered: