<?php
namespace App\Mail;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class OrderPlacedMail extends Mailable {
    use SerializesModels;
    public $order; public $role;
    
    public function __construct($order, $role) { 
        $this->order = $order; 
        $this->role = $role; 
    }
    
    public function build() {
        $subject = $this->role === 'buyer' 
            ? __('Order Placed Successfully - #:order', ['order' => $this->order->order_number])
            : __('New Order Received - #:order', ['order' => $this->order->order_number]);

        return $this->subject($subject)->view('emails.orders.placed');
    }
}