completed story 1.1 with QA tests and fixes
This commit is contained in:
@@ -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'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user