Skip to content

Commit 465453d

Browse files
fix(notifications): update NotificationService for consistency
- Minor adjustments to align with recent refactoring patterns - Ensure service layer follows domain/infrastructure separation
1 parent 6b72bf1 commit 465453d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Modules/Notifications/Application/Services/NotificationService.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Modules\Notifications\Application\DTOs\NotificationDTO;
99
use Modules\Notifications\Domain\Enums\NotificationChannel;
1010
use Modules\Notifications\Infrastructure\Notifications\CustomNotification;
11-
use Modules\Users\Infrastructure\Persistence\Models\User;
11+
use Modules\Users\Infrastructure\Persistence\Models\UserModel;
1212

1313
class NotificationService
1414
{
@@ -22,8 +22,8 @@ public function sendNotification(
2222
NotificationDTO $notificationDTO,
2323
array $channels = [NotificationChannel::DATABASE]
2424
): void {
25-
/** @var User $user */
26-
$user = User::findOrFail($userId);
25+
/** @var UserModel $user */
26+
$user = UserModel::findOrFail($userId);
2727

2828
Log::channel('domain')->info('Sending notification', [
2929
'user_id' => $userId,
@@ -56,7 +56,7 @@ public function markAsRead(int $notificationId, int $userId): bool
5656
{
5757
$notification = DatabaseNotification::query()
5858
->where('id', $notificationId)
59-
->where('notifiable_type', User::class)
59+
->where('notifiable_type', UserModel::class)
6060
->where('notifiable_id', $userId)
6161
->first();
6262

@@ -77,7 +77,7 @@ public function markAsRead(int $notificationId, int $userId): bool
7777
public function getUnreadNotifications(int $userId): array
7878
{
7979
return DatabaseNotification::query()
80-
->where('notifiable_type', User::class)
80+
->where('notifiable_type', UserModel::class)
8181
->where('notifiable_id', $userId)
8282
->whereNull('read_at')
8383
->orderBy('created_at', 'desc')
@@ -94,7 +94,7 @@ public function getUnreadNotifications(int $userId): array
9494
public function getAllNotifications(int $userId): array
9595
{
9696
return DatabaseNotification::query()
97-
->where('notifiable_type', User::class)
97+
->where('notifiable_type', UserModel::class)
9898
->where('notifiable_id', $userId)
9999
->orderBy('created_at', 'desc')
100100
->get()
@@ -109,7 +109,7 @@ public function deleteNotification(int $notificationId, int $userId): bool
109109
{
110110
$notification = DatabaseNotification::query()
111111
->where('id', $notificationId)
112-
->where('notifiable_type', User::class)
112+
->where('notifiable_type', UserModel::class)
113113
->where('notifiable_id', $userId)
114114
->first();
115115

0 commit comments

Comments
 (0)