Completed
Push — master ( f8d577...6d4239 )
by Freek
18s queued 11s
created

EloquentSnapshot::scopeUuid()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Spatie\EventSourcing\Snapshots;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
8
class EloquentSnapshot extends Model
9
{
10
    public $guarded = [];
11
12
    public $timestamps = false;
13
14
    protected $table = 'snapshots';
15
16
    public $casts = [
17
        'state' => 'array',
18
    ];
19
20
    public function toSnapshot(): Snapshot
21
    {
22
        return new Snapshot($this->aggregate_uuid, $this->aggregate_version, $this->state);
23
    }
24
25
    public function scopeUuid(Builder $query, string $uuid): void
26
    {
27
        $query->where('aggregate_uuid', $uuid);
28
    }
29
}
30