Skip to content

Serializing or Normalizing of DataCollection #450

Answered by sebastiandedeyne
jstoone asked this question in Q&A
Discussion options

You must be logged in to vote

Hi Jakob,

Unfortunately I don't have time for an in-depth answer now. In one of our client projects we're in the process of using Laravel Data for all stored events with a custom serializer. We should have it complete in January, and I'll attempt to document it somewhere after.

But, here's how we're planning to use Laravel Data with this package:

1. Each stored event will be a data object. The data package can also be used with a trait instead of inheritance.

use Spatie\EventSourcing\StoredEvents\ShouldBeStored;
use Spatie\LaravelData\Concerns\DataTrait;

class ResourceIdentified extends ShouldBeStored
{
    use DataTrait;

    public function __construct(
        public string $resourceId,…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@jstoone
Comment options

Answer selected by jstoone
Comment options

You must be logged in to vote
1 reply
@sebastiandedeyne
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants