1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2024-11-25 03:43:33 +01:00
freescout/app/Observers/ConversationObserver.php
2018-09-30 10:38:38 -07:00

42 lines
835 B
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();
}
}