<?php

namespace App\Mail;

use App\Models\Message;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class NewChatMessageNotification extends Mailable
{
    use Queueable, SerializesModels;

    public $message;

   public function __construct(Message $message)
{
    $message->load('sender', 'receiver');
    $this->message = $message;
}

    public function build()
    {
        return $this->subject('You received a new message')
                    ->view('emails.new_message');
    }
}
 
