<?php

namespace App\Notifications;

use App\Models\Transaction;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class ReceiptConfirmed extends Notification implements ShouldQueue
{
    use Queueable;

    /**
     * Create a new notification instance.
     */
    public function __construct(
        private Transaction $transaction
    ) {
    }

    /**
     * Get the notification's delivery channels.
     */
    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     */
    public function toMail(object $notifiable): MailMessage
    {
        $url = route('transactions.show', $this->transaction);

        return (new MailMessage)
            ->subject("Receipt Confirmed - Transaction Complete")
            ->greeting("Transaction Complete!")
            ->line("The buyer has confirmed receipt of your item.")
            ->line('')
            ->line("Item: {$this->transaction->item->title}")
            ->line("Buyer: {$this->transaction->buyer->name}")
            ->line('')
            ->line("Thank you for selling on Xeek!")
            ->action('View Transaction', $url);
    }
}
