From 66d45bf7f6effaa8f76faf125ff0fd1f9ffea1d8 Mon Sep 17 00:00:00 2001 From: FreeScout Date: Tue, 6 Dec 2022 22:39:42 -0800 Subject: [PATCH] Entities hooks --- app/Observers/ConversationObserver.php | 7 +++++++ app/Observers/ThreadObserver.php | 12 ++++++++++++ app/Thread.php | 1 + 3 files changed, 20 insertions(+) diff --git a/app/Observers/ConversationObserver.php b/app/Observers/ConversationObserver.php index 419f0afd..ee46d358 100644 --- a/app/Observers/ConversationObserver.php +++ b/app/Observers/ConversationObserver.php @@ -37,5 +37,12 @@ class ConversationObserver public function deleting(Conversation $conversation) { $conversation->threads()->delete(); + + \Eventy::action('conversation.deleting', $conversation); + } + + public function updated(Conversation $conversation) + { + \Eventy::action('conversation.updated', $conversation); } } diff --git a/app/Observers/ThreadObserver.php b/app/Observers/ThreadObserver.php index 637e510e..24549860 100644 --- a/app/Observers/ThreadObserver.php +++ b/app/Observers/ThreadObserver.php @@ -74,5 +74,17 @@ class ThreadObserver ) { Conversation::refreshConversations($conversation, $thread); } + + \Eventy::action('thread.created', $thread); + } + + public function deleting(Thread $thread) + { + \Eventy::action('thread.deleting', $thread); + } + + public function updated(Thread $thread) + { + \Eventy::action('thread.updated', $thread); } } diff --git a/app/Thread.php b/app/Thread.php index 81ac2e22..3fd015a3 100644 --- a/app/Thread.php +++ b/app/Thread.php @@ -56,6 +56,7 @@ class Thread extends Model //self::TYPE_FORWARDPARENT => 'forwardparent', // forwardchild is the type set on the first thread of the new forwarded conversation. //self::TYPE_FORWARDCHILD => 'forwardchild', + // Not used. self::TYPE_CHAT => 'chat', ];