<?php

namespace App\Notifications;

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

class ErrorOccurredNotification extends Notification
{
    use Queueable;

    protected $exception;

    public function __construct($exception)
    {
        $this->exception = $exception;
    }

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

    public function toMail($notifiable)
    {
        return (new MailMessage)
            ->subject('Laporan Stok Malam Error Notification')
            ->line('Terjadi error di aplikasi:')
            ->line($this->exception->getMessage())
            ->line('File: ' . $this->exception->getFile())
            ->line('Line: ' . $this->exception->getLine())
            ->line('Trace:')
            ->line($this->exception->getTraceAsString());
    }
}
