Completed
Push — master ( 3f2c58...3eb51e )
by wen
02:00
created

AbstractEvent::getAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
4
namespace Sco\ActionLog\Events;
5
6
use Illuminate\Database\Eloquent\Model;
7
use Sco\ActionLog\Handlers\EventHandler;
8
use Sco\ActionLog\Traits\HasAttributes;
9
10
abstract class AbstractEvent
11
{
12
    use HasAttributes;
13
14
    public $type;
15
16
    public $logInfo;
17
18
    public function __construct(Model $model)
19
    {
20
        $this->setAttribute([
21
            'model.original'   => $model->getOriginal(),
22
            'model.attributes' => $model->getAttributes(),
23
        ]);
24
25
        $handler = new EventHandler($this, $model);
26
27
        $this->logInfo = $handler->info();
28
    }
29
30
    public function getContent()
31
    {
32
        return [
33
            'from' => $this->getAttribute('model.original'),
34
            'to'   => $this->getAttribute('model.attributes'),
35
        ];
36
    }
37
38
39
}
40