<?php

namespace App\Events;

use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class UserNotificationEvent implements ShouldBroadcast
{
  use InteractsWithSockets, SerializesModels;

  public $message;
  public $targetCompany;

  public function __construct($targetCompany, $message)
  {
      $this->targetCompany = $targetCompany;
      $this->message = $message;
  }

  public function broadcastOn()
  {
      return ['notifications.company.'.$this->targetCompany->id];
  }

  public function broadcastAs()
  {
      return 'notification';
  }
}
