- Add database migrations for plans, subscriptions, notification preferences, and notification log tables - Implement DispatchUserNotificationJob to handle channel resolution, daily limits, and logging (sent/tier_restricted/daily_limit) - Add SendScheduledWhatsAppJob for scheduled notification delivery - Create PlanFeatures service to resolve tier capabilities, check daily limits, and validate fuel
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Enums\FuelType;
|
|
use App\Models\NotificationLog;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<NotificationLog>
|
|
*/
|
|
class NotificationLogFactory extends Factory
|
|
{
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'user_id' => User::factory(),
|
|
'channel' => fake()->randomElement(['email', 'push', 'whatsapp', 'sms']),
|
|
'trigger_type' => fake()->randomElement(['price_threshold', 'score_change', 'scheduled_morning', 'scheduled_evening']),
|
|
'fuel_type' => fake()->randomElement(array_column(FuelType::cases(), 'value')),
|
|
'price' => fake()->optional()->randomFloat(3, 100, 180),
|
|
'sent' => true,
|
|
'missed_reason' => null,
|
|
'created_at' => now(),
|
|
];
|
|
}
|
|
|
|
public function missed(string $reason = 'daily_limit'): static
|
|
{
|
|
return $this->state(fn () => [
|
|
'sent' => false,
|
|
'missed_reason' => $reason,
|
|
]);
|
|
}
|
|
}
|