Backend: - Create notifications table (user_id, workspace_id, type, channel, title, body, data JSON, read_at, archived_at) - Create Notification model with Type enum (post_failed, account_disconnected, invite_received, member_joined, member_removed) and Channel enum (email, in_app, both) - Create SendNotification job: isolated from publish flow, handles saving in-app notification and sending email independently - NotificationController: index (excludes archived, scoped to workspace), markAsRead, markAllAsRead, archiveAll - Integrate with PublishToSocialPlatform (post failed/partial) - Integrate with VerifyWorkspaceConnections (batch disconnection) - Integrate with SocialAccount::markAsDisconnected (single disconnection) - All use SendNotification::dispatch() instead of direct Mail::to() Frontend: - NotificationBell component in sidebar footer with unread badge - Dialog with notification list, mark as read, mark all read, archive all - Click navigates to relevant page (post edit, accounts) - i18n for notifications UI (en, es, pt-BR) Tests: - 8 tests for NotificationController (auth, CRUD, workspace scoping) - 4 tests for SendNotification job (channels, email, data storage) All 745 tests passing.
37 lines
880 B
PHP
37 lines
880 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\Notification\Channel;
|
|
use App\Enums\Notification\Type;
|
|
use App\Models\Notification;
|
|
use App\Models\User;
|
|
use App\Models\Workspace;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Notification>
|
|
*/
|
|
class NotificationFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'workspace_id' => Workspace::factory(),
|
|
'type' => fake()->randomElement(Type::cases()),
|
|
'channel' => Channel::InApp,
|
|
'title' => fake()->sentence(4),
|
|
'body' => fake()->sentence(10),
|
|
'data' => null,
|
|
'read_at' => null,
|
|
];
|
|
}
|
|
|
|
public function read(): static
|
|
{
|
|
return $this->state(fn () => ['read_at' => now()]);
|
|
}
|
|
}
|