BaseModelEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 6
nop 1
1
<?php
2
3
4
namespace Sco\ActionLog\Events;
5
6
use Illuminate\Database\Eloquent\Model;
7
use Sco\Attributes\HasAttributesTrait;
8
9
class BaseModelEvent extends Event
10
{
11
    use HasAttributesTrait;
12
13
    public function __construct(Model $model)
14
    {
15
        $this->setAttribute([
16
            'model.table'      => $model->getTable(),
17
            'model.original'   => $model->getOriginal(),
18
            'model.attributes' => $model->getAttributes(),
19
        ]);
20
21
        parent::__construct();
22
    }
23
24
    protected function getContent()
25
    {
26
        return [
27
            'table'      => $this->getAttribute('model.table', ''),
28
            'original'   => $this->getAttribute('model.original', []),
29
            'attributes' => $this->getAttribute('model.attributes', []),
30
        ];
31
    }
32
}
33