mirror of
https://gh.wpcy.net/https://github.com/rilustrisimo/freescout-support.git
synced 2026-04-25 13:52:21 +08:00
49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?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);
|
|
}
|
|
}
|