Passed
Push — master ( f51c1b...16736d )
by Arthur
05:36
created

MachineUpdatedEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A broadcastWith() 0 3 1
A broadcastOn() 0 3 1
A broadcastAs() 0 3 1
A __construct() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 14.10.18
6
 * Time: 19:31.
7
 */
8
9
namespace Modules\Machine\Events;
10
11
use Foundation\Abstracts\Events\Event;
12
use Illuminate\Broadcasting\PrivateChannel;
13
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
14
use Modules\Machine\Entities\Machine;
15
use Modules\Machine\Resources\MachineResource;
16
17
class MachineUpdatedEvent extends Event implements ShouldBroadcast
18
{
19
    public $listeners = [];
20
21
    /**
22
     * @var Machine
23
     */
24
    public $machine;
25
26
    /**
27
     * UserRegisteredEvent constructor.
28
     *
29
     * @param $user
30
     */
31
    public function __construct(Machine $machine)
32
    {
33
        $this->machine = $machine;
34
    }
35
36
    public function broadcastOn()
37
    {
38
        return new PrivateChannel('user.' . $this->machine->user_id);
0 ignored issues
show
Bug introduced by
The property user_id does not exist on Modules\Machine\Entities\Machine. Did you mean user?
Loading history...
39
    }
40
41
    public function broadcastAs()
42
    {
43
        return 'machine.updated';
44
    }
45
46
    public function broadcastWith()
47
    {
48
        return (new MachineResource($this->machine))->toArray(null);
49
    }
50
}
51