Skip to content

Commit

Permalink
Support legacy spatie/laravel-schemaless-attributes:^1.0 as well
Browse files Browse the repository at this point in the history
  • Loading branch information
brendt committed Jun 14, 2021
1 parent 7530cff commit 4b57dcc
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-event-sourcing` will be documented in this file:

## 5.0.2 - 2021-06-14

- Support legacy `spatie/laravel-schemaless-attributes:^1.0` as well

## 5.0.1 - 2021-06-10

- move migrations to default location
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"league/flysystem": "^1.1.3",
"phpdocumentor/reflection-docblock": "^5.2",
"spatie/laravel-package-tools": "^1.9",
"spatie/laravel-schemaless-attributes": "^2.0",
"spatie/laravel-schemaless-attributes": "^1.0|^2.0",
"symfony/finder": "^4.2|^5.0",
"symfony/property-access": "^4.0|^5.0",
"symfony/property-info": "^5.2",
Expand Down
5 changes: 5 additions & 0 deletions src/StoredEvents/Models/EloquentStoredEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public function newCollection(array $models = []): EloquentStoredEventCollection

public function scopeWithMetaDataAttributes(): Builder
{
// Legacy support for laravel-schemaless-attributes:^1.0
if (! method_exists($this->meta_data, 'modelScope')) {
return $this->meta_data->scopeWithSchemalessAttributes('meta_data');
}

return $this->meta_data->modelScope();
}
}
2 changes: 1 addition & 1 deletion tests/Models/StoredEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function it_will_store_the_alias_when_a_classname_is_found_in_the_event_c
public function it_allows_to_modify_metadata_with_offset_set_in_eloquent_model()
{
EloquentStoredEvent::creating(function (EloquentStoredEvent $event) {
$event->meta_data['ip'] = '127.0.0.1';
$event->meta_data->set('ip', '127.0.0.1');
});

$this->setConfig('event-sourcing.event_class_map', [
Expand Down

0 comments on commit 4b57dcc

Please sign in to comment.