1 | <?php |
||
12 | class StoredEvent extends Model |
||
13 | { |
||
14 | public $guarded = []; |
||
15 | |||
16 | public $timestamps = false; |
||
17 | |||
18 | public $casts = [ |
||
19 | 'event_properties' => 'array', |
||
20 | 'meta_data' => 'array', |
||
21 | ]; |
||
22 | |||
23 | public static function createForEvent(ShouldBeStored $event): StoredEvent |
||
24 | { |
||
25 | $storedEvent = new static(); |
||
26 | $storedEvent->event_class = get_class($event); |
||
27 | $storedEvent->attributes['event_properties'] = app(EventSerializer::class)->serialize(clone $event); |
||
28 | $storedEvent->meta_data = []; |
||
29 | $storedEvent->created_at = now(); |
||
30 | |||
31 | $storedEvent->save(); |
||
32 | |||
33 | return $storedEvent; |
||
34 | } |
||
35 | |||
36 | public static function getMaxId(): int |
||
40 | |||
41 | public function getEventAttribute(): ShouldBeStored |
||
48 | |||
49 | public function scopeAfter(Builder $query, int $storedEventId) |
||
53 | |||
54 | public function scopeUntil(Builder $query, int $storedEventId = null) |
||
60 | |||
61 | public function getMetaDataAttribute(): SchemalessAttributes |
||
65 | |||
66 | public function scopeWithMetaDataAttributes(): Builder |
||
70 | } |
||
71 |