<?php

namespace App\Http\Resources\Notifications;

use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class NotificationResource extends JsonResource
{
    public function toArray(Request $request): array
    {
        return [
            'id' => (int) ($this->id ?? 0),
            'title' => $this->title,
            'message' => $this->message,
            'target_group' => $this->target_group,
            'delivery_channels' => $this->delivery_channels,
            'priority' => $this->priority,
            'status' => $this->status,
            'action_url' => $this->action_url,
            'attachment_path' => $this->attachment_path,
            'scheduled_at' => optional($this->scheduled_at)->toDateTimeString(),
            'sent_at' => optional($this->sent_at)->toDateTimeString(),
            'expires_at' => optional($this->expires_at)->toDateTimeString(),
            'school_year' => $this->school_year,
            'semester' => $this->semester,
            'created_at' => optional($this->created_at)->toDateTimeString(),
            'updated_at' => optional($this->updated_at)->toDateTimeString(),
        ];
    }
}
