freescout/freescout-dist/app/Observers/ConversationObserver.php

50 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2023-12-22 19:40:32 +00:00
<?php
namespace App\Observers;
use App\Conversation;
class ConversationObserver
{
/**
* On create before saving.
*
* @param Conversation $conversation
*/
public function creating(Conversation $conversation)
{
if ($conversation->source_via == Conversation::PERSON_USER) {
$conversation->read_by_user = true;
}
}
/**
* On create.
*
* @param Conversation $conversation
*/
public function created(Conversation $conversation)
{
// Better to do it manually
//$conversation->mailbox->updateFoldersCounters();
}
/**
* On conversation delete.
*
* @param Conversation $conversation
*/
public function deleting(Conversation $conversation)
{
$conversation->threads()->delete();
$conversation->followers()->delete();
\Eventy::action('conversation.deleting', $conversation);
}
public function updated(Conversation $conversation)
{
\Eventy::action('conversation.updated', $conversation);
}
}