Passed
Push — master ( c13b73...f2713c )
by Arthur
05:06
created

AccountUpdatedEvent::broadcastOn()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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