roles = Role::where('name', '!=', 'Developer')->orderBy('id')->pluck('name', 'id')->toArray(); } public function create(): void { $this->canOrAbort('create broadcast'); $result = $this->form->store(); $userIds = User::role(array_map('intval', $result['audience_ids']))->pluck('id')->toArray(); StorePushNotification::dispatch( PushNotification::whereIn('user_id', $userIds)->get(), [ 'title' => $result['title'], 'body' => $result['body'], ], ); $this->dispatch('refreshDatatable'); $this->toast('Broadcast berhasil ditambahkan.'); Flux::modals()->close(); } public function delete(BroadcastModel $broadcast): void { $this->canOrAbort('delete broadcast'); $broadcast->delete(); $this->dispatch('refreshDatatable'); $this->toast('Broadcast berhasil dihapus.'); Flux::modals()->close(); } #[On('modal:open')] public function openModal(string $method, string $modalTitle, ?string $id = null): void { $this->resetValidation(); $this->resetErrorBag(); $this->method = $method; $this->modalTitle = $modalTitle; if ($id) { $this->form->setBroadcast(BroadcastModel::byHashOrFail($id)); } } public function render(): View { return view('livewire.studio.information.broadcasts', [ 'pageTitle' => 'Broadcast', ]); } }