Skip to content

Commit f56f4dc

Browse files
authored
Merge pull request #496 from maartenpaauw/feature/eloquent-generic-typings
feat: add eloquent stored event generic types for collection and query builder
2 parents 12028ba + 9318efb commit f56f4dc

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/StoredEvents/Models/EloquentStoredEvent.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,17 @@ public function getMetaDataAttribute(): SchemalessAttributes
6969
return SchemalessAttributes::createForModel($this, 'meta_data');
7070
}
7171

72+
/**
73+
* @return EloquentStoredEventQueryBuilder<$this>
74+
*/
7275
public function newEloquentBuilder($query): EloquentStoredEventQueryBuilder
7376
{
7477
return new EloquentStoredEventQueryBuilder($query);
7578
}
7679

80+
/**
81+
* @return EloquentStoredEventCollection<$this>
82+
*/
7783
public function newCollection(array $models = []): EloquentStoredEventCollection
7884
{
7985
return new EloquentStoredEventCollection($models);

src/StoredEvents/Models/EloquentStoredEventCollection.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
use Illuminate\Database\Eloquent\Collection as EloquentCollection;
66
use Illuminate\Support\Collection;
77

8+
/**
9+
* @template TEloquentStoredEvent of EloquentStoredEvent
10+
*
11+
* @extends EloquentCollection<array-key, TEloquentStoredEvent>
12+
*/
813
class EloquentStoredEventCollection extends EloquentCollection
914
{
1015
/**

src/StoredEvents/Models/EloquentStoredEventQueryBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66
use Spatie\EventSourcing\StoredEvents\StoredEvent;
77

88
/**
9-
* @method \Spatie\EventSourcing\StoredEvents\Models\EloquentStoredEventCollection get
9+
* @template TEloquentStoredEvent of EloquentStoredEvent
10+
*
11+
* @method \Spatie\EventSourcing\StoredEvents\Models\EloquentStoredEventCollection<EloquentStoredEvent> get()
12+
*
13+
* @extends Builder<TEloquentStoredEvent>
1014
*/
1115
class EloquentStoredEventQueryBuilder extends Builder
1216
{

0 commit comments

Comments
 (0)