-
-
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
Carbon Objects don't work with Datatables when using getCreatedAtAttribute
#3160
Comments
It seems related to this issue: #3156, I will try to fix it when I get the chance. Please do not hesitate to submit a PR if you can. Thanks! |
I ended up making a Trait to use in the model for the time being, it's working pretty well
|
I tried adding the getter and it is serialized just fine. Before processing on https://github.com/yajra/laravel-datatables/blob/master/src/Utilities/Helper.php#L204: array:18 [▼ // vendor/yajra/laravel-datatables-oracle/src/Utilities/Helper.php:209
"id" => 1
"name" => "Elaina Russel"
"username" => null
"email" => "joanne.jenkins@example.com"
"email_verified_at" => "2024-08-17T03:21:35.000000Z"
"two_factor_confirmed_at" => null
"current_team_id" => null
"profile_photo_path" => null
"last_login_at" => null
"password_changed_at" => null
"blocked_at" => null
"must_change_password" => false
"can_be_impersonated" => true
"created_at" => Illuminate\Support\Carbon @1723864896 {#1828 ▼
#endOfTime: false
#startOfTime: false
#constructedObjectId: "00000000000007240000000000000000"
-clock: null
#localMonthsOverflow: null
#localYearsOverflow: null
#localStrictModeEnabled: null
#localHumanDiffOptions: null
#localToStringFormat: null
#localSerializer: null
#localMacros: null
#localGenericMacros: null
#localFormatFunction: null
#localTranslator: null
#dumpProperties: array:3 [▶]
#dumpLocale: null
#dumpDateProperties: null
date: 2024-08-16 23:21:36.0 America/New_York (-04:00)
}
"updated_at" => "2024-08-17T03:21:36.000000Z"
"created_by" => null
"updated_by" => null
"profile_photo_url" => "https://ui-avatars.com/api/?name=E+R&color=056EE9&background=F0F9FF"
] After processing: array:18 [▼ // routes/web.php:18
"id" => 1
"name" => "Elaina Russel"
"username" => null
"email" => "joanne.jenkins@example.com"
"email_verified_at" => "2024-08-17T03:21:35.000000Z"
"two_factor_confirmed_at" => null
"current_team_id" => null
"profile_photo_path" => null
"last_login_at" => null
"password_changed_at" => null
"blocked_at" => null
"must_change_password" => false
"can_be_impersonated" => true
"created_at" => "2024-08-16 23:21:36"
"updated_at" => "2024-08-17T03:21:36.000000Z"
"created_by" => null
"updated_by" => null
"profile_photo_url" => "https://ui-avatars.com/api/?name=E+R&color=056EE9&background=F0F9FF"
] Please elaborate on the issue, I might be missing something. Thanks! |
Whoops, I was testing using the latest version with #3163. Can you update your version and advise if the PR resolves this issue? Thanks! |
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been inactive for 7 days since being marked as stale. |
Summary of problem or feature request
When overriding the getter for the created_at on the model level, the column will display [object object] rather than the formatted datetime. By default, created_at passes as a Carbon object so it can be used in other areas and by being able to call
->format
on it. The only work around I found for this is doing an editColumn and then formatting it from there. It just seems tedious that Datatables doesn't support Carbon objects.Code snippet of problem
System details
AlmaLinux 8.7
8.2
10
10
The text was updated successfully, but these errors were encountered: