Skip to content

Change Carbon include to fix SerializeUsing & jsonSerialize incosistency #1378

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

Closed
wants to merge 1 commit into from

Conversation

Christophvh
Copy link

@Christophvh Christophvh commented Nov 30, 2017

Changed the Carbon include to use the extended version of Laravel.

use Carbon\Carbon => use Illuminate\Support\Carbon

This way we can use the jsonSerialize() and serializeUsing(). methods

For example in the new ApiResources in Laravel 5.5 we can specify a global serialization for Carbon dates:

   
Carbon::serializeUsing(function ($carbon) {
            return $carbon->format('U');
        });

https://laravel.com/docs/5.5/eloquent-serialization#date-serialization

Changed the Carbon include to use the extended version of Laravel.

`use Carbon\Carbon` => `use Illuminate\Support\Carbon`

This way we can use the `jsonSerialize()` and  `serializeUsing`.

For example in the new ApiResources in Laravel 5.5 we can specify a global serialization for Carbon dates: 
   ````Carbon::serializeUsing(function ($carbon) {
            return $carbon->format('U');
        });````

https://laravel.com/docs/5.5/eloquent-serialization#date-serialization
@Christophvh Christophvh changed the title Change Carbon include Change Carbon include to fix SerializieUising Nov 30, 2017
@Christophvh Christophvh changed the title Change Carbon include to fix SerializieUising Change Carbon include to fix SerializieUsing Nov 30, 2017
@Christophvh Christophvh changed the title Change Carbon include to fix SerializieUsing Change Carbon include to fix SerializeUsing & jsonSerialize Nov 30, 2017
@Christophvh Christophvh changed the title Change Carbon include to fix SerializeUsing & jsonSerialize Change Carbon include to fix SerializeUsing & jsonSerialize Aug 23, 2018
@Christophvh Christophvh changed the title Change Carbon include to fix SerializeUsing & jsonSerialize Change Carbon include to fix SerializeUsing & jsonSerialize incosistency Aug 23, 2018
@Christophvh Christophvh reopened this Aug 23, 2018
@divine
Copy link
Contributor

divine commented Jan 20, 2020

Hello!

Could you please update with the base branch or we can take a look?

Thank you for your contribution!

@Giacomo92
Copy link

It can be closed @jenssegers

@divine divine closed this Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants