refactor: use laravel notifications for system user private messages

This commit is contained in:
Roardom
2025-01-25 09:41:14 +00:00
parent 18ba1a5cc5
commit 6a103cee97
32 changed files with 1007 additions and 122 deletions
-26
View File
@@ -976,32 +976,6 @@ class User extends Authenticatable implements MustVerifyEmail
return $this->hasMany(Donation::class);
}
public function sendSystemNotification(string $subject, string $message): void
{
$conversation = Conversation::create(['subject' => $subject]);
$conversation->users()->sync([User::SYSTEM_USER_ID => ['read' => true], $this->id]);
PrivateMessage::create([
'conversation_id' => $conversation->id,
'sender_id' => self::SYSTEM_USER_ID,
'message' => $message
]);
}
public static function sendSystemNotificationTo(int $userId, string $subject, string $message): void
{
$conversation = Conversation::create(['subject' => $subject]);
$conversation->users()->sync([User::SYSTEM_USER_ID => ['read' => true], $userId]);
PrivateMessage::create([
'conversation_id' => $conversation->id,
'sender_id' => self::SYSTEM_USER_ID,
'message' => $message
]);
}
/**
* Has many conversations.
*