BaseModelEvent::setModel()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: alive
5
 * Date: 12/11/17
6
 * Time: 7:55 AM
7
 */
8
9
namespace Alive2212\LaravelModelEventService\Events;
10
11
use Illuminate\Queue\SerializesModels;
12
use Illuminate\Broadcasting\PrivateChannel;
13
use Illuminate\Foundation\Events\Dispatchable;
14
use Illuminate\Broadcasting\InteractsWithSockets;
15
16
17
class BaseModelEvent
18
{
19
    use Dispatchable, InteractsWithSockets, SerializesModels;
20
21
    /**
22
     * @var
23
     */
24
    protected $model;
25
26
    /**
27
     * Create a new event instance.
28
     * @param $model
29
     */
30
    public function __construct($model)
31
    {
32
        $this->model = $model[0];
33
    }
34
35
    /**
36
     * Get the channels the event should broadcast on.
37
     *
38
     * @return PrivateChannel
39
     */
40
    public function broadcastOn()
41
    {
42
        return new PrivateChannel('channel-name');
43
    }
44
45
    /**
46
     * @return mixed
47
     */
48
    public function getModel()
49
    {
50
        return $this->model;
51
    }
52
53
    /**
54
     * @param mixed $model
55
     */
56
    public function setModel($model)
57
    {
58
        $this->model = $model;
59
    }
60
}