CredentialDeleted.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Events;
  3. use Illuminate\Broadcasting\Channel;
  4. use Illuminate\Broadcasting\InteractsWithSockets;
  5. use Illuminate\Broadcasting\PresenceChannel;
  6. use Illuminate\Broadcasting\PrivateChannel;
  7. use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  8. use Illuminate\Foundation\Events\Dispatchable;
  9. use Illuminate\Queue\SerializesModels;
  10. use App\Credential;
  11. class CredentialDeleted implements ShouldBroadcast
  12. {
  13. use Dispatchable, InteractsWithSockets, SerializesModels;
  14. public $credential;
  15. /**
  16. * Create a new event instance.
  17. *
  18. * @return void
  19. */
  20. public function __construct($credential)
  21. {
  22. $array = json_decode($credential, true);
  23. $this->credential = $array;
  24. }
  25. /**
  26. * Get the channels the event should broadcast on.
  27. *
  28. * @return \Illuminate\Broadcasting\Channel|array
  29. */
  30. public function broadcastOn()
  31. {
  32. if ($this->credential['pcid'] != 0) {
  33. return new Channel('credlist.pcid.'.$this->credential['pcid']);
  34. } else {
  35. return new Channel('credlist.groupid.'.$this->credential['groupid']);
  36. }
  37. }
  38. }