complete story 4.2 with qa tests

This commit is contained in:
Naser Mansour
2025-12-27 00:30:38 +02:00
parent e669e97ca1
commit 435b1c6c2e
21 changed files with 1495 additions and 40 deletions
+8
View File
@@ -6,4 +6,12 @@ enum TimelineStatus: string
{
case Active = 'active';
case Archived = 'archived';
public function label(): string
{
return match ($this) {
self::Active => __('enums.timeline_status.active'),
self::Archived => __('enums.timeline_status.archived'),
};
}
}
+2 -2
View File
@@ -35,10 +35,10 @@ class Timeline extends Model
}
/**
* Get the updates for the timeline.
* Get the updates for the timeline, ordered chronologically (oldest first).
*/
public function updates(): HasMany
{
return $this->hasMany(TimelineUpdate::class);
return $this->hasMany(TimelineUpdate::class)->orderBy('created_at', 'asc');
}
}
@@ -0,0 +1,72 @@
<?php
namespace App\Notifications;
use App\Models\TimelineUpdate;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class TimelineUpdateNotification extends Notification implements ShouldQueue
{
use Queueable;
/**
* Create a new notification instance.
*/
public function __construct(
public TimelineUpdate $timelineUpdate
) {}
/**
* Get the notification's delivery channels.
*
* @return array<int, string>
*/
public function via(object $notifiable): array
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*/
public function toMail(object $notifiable): MailMessage
{
$locale = $notifiable->preferred_language ?? 'ar';
return (new MailMessage)
->subject($this->getSubject($locale))
->view('emails.timeline-update', [
'timelineUpdate' => $this->timelineUpdate,
'timeline' => $this->timelineUpdate->timeline,
'locale' => $locale,
'user' => $notifiable,
]);
}
/**
* Get the subject based on locale.
*/
private function getSubject(string $locale): string
{
return $locale === 'ar'
? 'تحديث جديد على قضيتك'
: 'New Update on Your Case';
}
/**
* Get the array representation of the notification.
*
* @return array<string, mixed>
*/
public function toArray(object $notifiable): array
{
return [
'type' => 'timeline_update',
'timeline_update_id' => $this->timelineUpdate->id,
'timeline_id' => $this->timelineUpdate->timeline_id,
];
}
}