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

Activity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A subject() 0 4 1
A causer() 0 4 1
A getExtraProperty() 0 4 1
A getChangesAttribute() 0 4 1
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