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

43 lines
874 B
PHP
Raw Normal View History

2023-12-22 19:40:32 +00:00
<?php
namespace App\Observers;
use App\Mailbox;
class MailboxObserver
{
/**
* Listen to the Mailbox created event.
*
* @param \App\Mailbox $mailbox
*
* @return void
*/
public function created(Mailbox $mailbox)
{
// Create folders
$mailbox->createPublicFolders();
$mailbox->syncPersonalFolders();
$mailbox->createAdminPersonalFolders();
}
/**
* Delete the following on mailbox delete:
* - folders
* - conversations
* - user permissions.
*
* @param Mailbox $mailbox
*
* @return [type] [description]
*/
public function deleting(Mailbox $mailbox)
{
$mailbox->users()->delete();
$mailbox->conversations()->delete();
$mailbox->folders()->delete();
\Eventy::action('mailbox.before_delete', $mailbox);
}
}