completed story 1.1 with QA tests and fixes

This commit is contained in:
Naser Mansour
2025-12-26 13:46:39 +02:00
parent 028ce573b9
commit 84d9c2f66a
57 changed files with 2193 additions and 85 deletions
@@ -0,0 +1,61 @@
<?php
namespace Database\Factories;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Notification>
*/
class NotificationFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'user_id' => User::factory(),
'type' => fake()->randomElement(['consultation_approved', 'consultation_rejected', 'timeline_update', 'new_post']),
'data' => [
'message' => fake()->sentence(),
'action_url' => fake()->url(),
],
'read_at' => null,
'sent_at' => fake()->optional()->dateTimeBetween('-7 days', 'now'),
];
}
/**
* Create a read notification.
*/
public function read(): static
{
return $this->state(fn (array $attributes) => [
'read_at' => fake()->dateTimeBetween('-7 days', 'now'),
]);
}
/**
* Create an unread notification.
*/
public function unread(): static
{
return $this->state(fn (array $attributes) => [
'read_at' => null,
]);
}
/**
* Create a sent notification.
*/
public function sent(): static
{
return $this->state(fn (array $attributes) => [
'sent_at' => fake()->dateTimeBetween('-7 days', 'now'),
]);
}
}