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

EventHandler::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
4
namespace Sco\ActionLog\Handlers;
5
6
use Auth;
7
use Illuminate\Database\Eloquent\Model;
8
use Sco\ActionLog\Events\AbstractEvent;
9
use Sco\ActionLog\LogInfo;
10
11
class EventHandler extends AbstractHandler
12
{
13
    private $event;
14
    private $model;
15
16
    public function __construct(AbstractEvent $event, Model $model)
17
    {
18
        $this->event = $event;
19
        $this->model = $model;
20
    }
21
22
    public function info()
23
    {
24
        return new LogInfo([
25
            'type'       => $this->event->type,
26
            'table_name' => $this->model->getTable(),
27
            'content'    => $this->event->getContent(),
28
            'client_ip'  => request()->getClientIp(),
29
            'client'     => $this->getClient(),
30
            'user_id'    => intval(Auth::id()),
31
        ]);
32
    }
33
}
34