69 lines
1.9 KiB
Markdown
69 lines
1.9 KiB
Markdown
# Story 8.7: Consultation Reminder (2 Hours)
|
|
|
|
## Epic Reference
|
|
**Epic 8:** Email Notification System
|
|
|
|
## User Story
|
|
As a **client**,
|
|
I want **to receive a reminder 2 hours before my consultation**,
|
|
So that **I'm prepared and ready**.
|
|
|
|
## Acceptance Criteria
|
|
|
|
### Trigger
|
|
- [ ] Scheduled job runs every 15 minutes
|
|
- [ ] Find consultations 2 hours away
|
|
- [ ] Only for approved consultations
|
|
- [ ] Skip cancelled/no-show
|
|
|
|
### Content
|
|
- [ ] "Your consultation is in 2 hours"
|
|
- [ ] Date and time
|
|
- [ ] Final payment reminder (if applicable)
|
|
- [ ] Contact info for last-minute issues
|
|
|
|
### Language
|
|
- [ ] Email in client's preferred language
|
|
|
|
## Technical Notes
|
|
|
|
```php
|
|
// Command: php artisan reminders:send-2h
|
|
// Schedule: everyFifteenMinutes
|
|
class Send2HourReminders extends Command
|
|
{
|
|
public function handle(): int
|
|
{
|
|
$targetTime = now()->addHours(2);
|
|
$windowStart = $targetTime->copy()->subMinutes(7);
|
|
$windowEnd = $targetTime->copy()->addMinutes(7);
|
|
|
|
Consultation::where('status', 'approved')
|
|
->whereNull('reminder_2h_sent_at')
|
|
->whereDate('scheduled_date', today())
|
|
->get()
|
|
->filter(function ($c) use ($windowStart, $windowEnd) {
|
|
$time = Carbon::parse($c->scheduled_date->format('Y-m-d') . ' ' . $c->scheduled_time);
|
|
return $time->between($windowStart, $windowEnd);
|
|
})
|
|
->each(function ($consultation) {
|
|
$consultation->user->notify(new ConsultationReminder2h($consultation));
|
|
$consultation->update(['reminder_2h_sent_at' => now()]);
|
|
});
|
|
|
|
return Command::SUCCESS;
|
|
}
|
|
}
|
|
```
|
|
|
|
## Definition of Done
|
|
- [ ] Command runs successfully
|
|
- [ ] Correct timing (2 hours before)
|
|
- [ ] Payment reminder if unpaid
|
|
- [ ] No duplicate reminders
|
|
- [ ] Bilingual templates
|
|
- [ ] Tests pass
|
|
|
|
## Estimation
|
|
**Complexity:** Medium | **Effort:** 2-3 hours
|