| Total Complexity | 5 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class MessageSent implements ShouldBroadcastNow |
||
| 16 | { |
||
| 17 | use Dispatchable, InteractsWithSockets, SerializesModels; |
||
|
|
|||
| 18 | |||
| 19 | public $message; |
||
| 20 | public $user; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Create a new event instance. |
||
| 24 | * |
||
| 25 | * @return void |
||
| 26 | */ |
||
| 27 | public function __construct(Message $message, User $user, public $conversation) |
||
| 31 | } |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Determine if this event should broadcast. |
||
| 35 | */ |
||
| 36 | public function broadcastWhen(): bool |
||
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * Get the data to broadcast. |
||
| 44 | * |
||
| 45 | * @return array |
||
| 46 | */ |
||
| 47 | public function broadcastWith() |
||
| 48 | { |
||
| 49 | return [ |
||
| 50 | 'user' => $this->user, |
||
| 51 | 'message' => $this->message, |
||
| 52 | 'conversation' => $this->conversation, |
||
| 53 | ]; |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Get the channels the event should broadcast on. |
||
| 58 | * |
||
| 59 | * @return \Illuminate\Broadcasting\Channel|array |
||
| 60 | */ |
||
| 61 | public function broadcastOn() |
||
| 62 | { |
||
| 63 | return new PrivateChannel('chat'); |
||
| 64 | } |
||
| 65 | |||
| 66 | public function broadcastAs(): string |
||
| 69 | } |
||
| 70 | } |
||
| 71 |