<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class MeterRejectedNotification extends Notification
{
    use Queueable;

    protected $reading;

    public function __construct($reading)
    {
        // Pastikan ini menerima data hasil API
        $this->reading = $reading;
    }

    public function via($notifiable)
    {
        return ['database'];
    }

    public function toDatabase($notifiable)
    {
        return [
            'meter_reading_id' => $this->reading->id ?? null,
            'title'   => 'Foto Meteran Ditolak',
            'message' => $this->reading->admin_note ?? 'Foto meteran Anda tidak sesuai, silakan upload ulang.',
            'month'   => $this->reading->month ?? '-',
        ];
    }
}