ObjectActionCreate.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Events;
  3. use App\Models\Action;
  4. use App\Models\Config;
  5. use App\Models\Enums\ConfigGroup;
  6. use Illuminate\Broadcasting\Channel;
  7. use Illuminate\Broadcasting\InteractsWithSockets;
  8. use Illuminate\Broadcasting\PresenceChannel;
  9. use Illuminate\Broadcasting\PrivateChannel;
  10. use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
  11. use Illuminate\Foundation\Events\Dispatchable;
  12. use Illuminate\Queue\SerializesModels;
  13. class ObjectActionCreate
  14. {
  15. use Dispatchable, InteractsWithSockets, SerializesModels;
  16. public array $notificationSetting = [];
  17. /**
  18. * Create a new event instance.
  19. */
  20. public function __construct(public Action $action)
  21. {
  22. $settingResult = Config::query()
  23. ->where("group", ConfigGroup::MESSAGE_NOTIFICATION)
  24. ->where("key", "setting")
  25. ->first();
  26. $this->notificationSetting = $settingResult ? json_decode($settingResult->value, true) : [];
  27. }
  28. /**
  29. * Get the channels the event should broadcast on.
  30. *
  31. * @return array<int, \Illuminate\Broadcasting\Channel>
  32. */
  33. public function broadcastOn(): array
  34. {
  35. return [
  36. new PrivateChannel('channel-name'),
  37. ];
  38. }
  39. }