Completed
Push — master ( c404ca...15b880 )
by Freek
02:00
created

Activity::causer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Spatie\Activitylog\Models;
4
5
use Eloquent;
6
use Illuminate\Database\Eloquent\Relations\MorphTo;
7
use Illuminate\Support\Collection;
8
9
class Activity extends Eloquent
10
{
11
    protected $table = 'activity_log';
12
13
    protected $casts = [
14
        'extra_properties' => 'collection',
15
    ];
16
17
    public function subject(): MorphTo
18
    {
19
        return $this->morphTo();
20
    }
21
22
    public function causer(): MorphTo
23
    {
24
        return $this->morphTo();
25
    }
26
27
    /**
28
     * Get the extra properties with the given name.
29
     *
30
     * @param $propertyName
31
     *
32
     * @return mixed
33
     */
34
    public function getExtraProperty(string $propertyName)
35
    {
36
        return array_get($this->extra_properties, $propertyName);
37
    }
38
39
    public function getChangesAttribute(): Collection
40
    {
41
        return collect($this->getExtraProperty('changes'));
42
    }
43
}
44