<?php

namespace App\Mail;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class ForumLikeMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(
        public User $recipient,
        public User $liker,
        public \App\Models\ForumPost $post,
        public \App\Models\ForumTopic $topic
    ) {
    }

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: $this->liker->name . ' mesajınızı beğendi — ' . config('app.name'),
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.forum-like',
            with: [
                'recipient' => $this->recipient,
                'liker'     => $this->liker,
                'post'      => $this->post,
                'topic'     => $this->topic,
                'postUrl'   => $this->topic->category
                    ? route('forum.topic', [$this->topic->category, $this->topic]) . '#post-' . $this->post->id
                    : route('forum.index'),
            ],
        );
    }
}
