feat: add ApiResponse trait for standardized API responses
chore: update composer dependencies to include phppresentation chore: update composer.lock after adding phppresentation feat: create categories migration for category management feat: create templates migration for template storage feat: create template generations migration for tracking template usage feat: create template keys migration for template customization feat: create notifications migration for user notifications feat: update API routes for categories, templates, and user profile management docs: update API documentation to include new endpoints for profile and wallet
This commit is contained in:
28
app/Services/NotificationService.php
Normal file
28
app/Services/NotificationService.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Enums\NotificationType;
|
||||
use App\Models\Notification;
|
||||
use App\Models\User;
|
||||
|
||||
class NotificationService
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed>|null $data
|
||||
*/
|
||||
public function send(User $user, NotificationType $type, string $title, string $body, ?array $data = null): Notification
|
||||
{
|
||||
return $user->notifications()->create([
|
||||
'type' => $type,
|
||||
'title' => $title,
|
||||
'body' => $body,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function markAllAsRead(User $user): void
|
||||
{
|
||||
$user->notifications()->whereNull('read_at')->update(['read_at' => now()]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user