© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Shaung Bhone

Filament with spatie event sourcing

I'm trying to create data with spatie event sourcing, when I create the data, event attribute gives me always null.
Currency.php
public static function createWithAttributes(array $attributes): self
{
    $attributes['uuid'] = (string) Uuid::uuid4();

    event(new CurrencyCreated(currencyAttributes: $attributes));

    return static::uuid($attributes['uuid']); <-- give me null
}
Currency.php
public static function createWithAttributes(array $attributes): self
{
    $attributes['uuid'] = (string) Uuid::uuid4();

    event(new CurrencyCreated(currencyAttributes: $attributes));

    return static::uuid($attributes['uuid']); <-- give me null
}

ListCurrencies.php
protected function getHeaderActions(): array
{
    return [
        Actions\CreateAction::make()
            ->createAnother(false)
            ->using(function (array $data, string $model): Model {
                return $model::createWithAttributes($data);
            })
            ->icon('heroicon-o-plus')
            ->label('Create')
            ->modalWidth(MaxWidth::Large),
    ];
}
ListCurrencies.php
protected function getHeaderActions(): array
{
    return [
        Actions\CreateAction::make()
            ->createAnother(false)
            ->using(function (array $data, string $model): Model {
                return $model::createWithAttributes($data);
            })
            ->icon('heroicon-o-plus')
            ->label('Create')
            ->modalWidth(MaxWidth::Large),
    ];
}

<?php

namespace App\Events;

use Spatie\EventSourcing\StoredEvents\ShouldBeStored;

class CurrencyCreated extends ShouldBeStored
{
    public function __construct(
        public array $currencyAttributes
    ){}
}
<?php

namespace App\Events;

use Spatie\EventSourcing\StoredEvents\ShouldBeStored;

class CurrencyCreated extends ShouldBeStored
{
    public function __construct(
        public array $currencyAttributes
    ){}
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Filament Spatie Translatable & Filament Spatie Tags
FilamentFFilament / ❓┊help
16mo ago
Filament Spatie FileUpload with s3
FilamentFFilament / ❓┊help
3y ago
Filament notifications & Spatie LogsActivity
FilamentFFilament / ❓┊help
8mo ago
filament-spatie-media-library
FilamentFFilament / ❓┊help
15mo ago