<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class OrderWebSubmittedMail extends Mailable
{
    public $fromEmail;
    public $toEmail;
    public $ccEmails;
    public $order_id;
    public $customer_name;
    public $extractedCardDetails;
    public $order_status;
    public $delivery_charge;
    public $over_all_total;
    public $deliveryDetails;
    public $order_description;
    public $total_amount;
    public $promocode_value;





 
    /**
     * Create a new message instance.
     *
     * @param string $fromEmail
     * @param string $toEmail
     */
    public function __construct($fromEmail, $toEmail, $ccEmails, $order_id, $customer_name,  $extractedCardDetails, $order_status, $delivery_charge, $over_all_total, $deliveryDetails, $order_description, $total_amount, $promocode_value)
    {
        $this->fromEmail                    =  $fromEmail;
        $this->toEmail                      = $toEmail;
        $this->ccEmails                     = $ccEmails;
        $this->order_id                     = $order_id;
        $this->customer_name                = $customer_name;
        $this->extractedCardDetails         = $extractedCardDetails;
        $this->order_status                 = $order_status;
        $this->delivery_charge              = $delivery_charge;
        $this->over_all_total               = $over_all_total;
        $this->deliveryDetails              = $deliveryDetails;
        $this->order_description            = $order_description;
        $this->total_amount                 = $total_amount;
        $this->promocode_value              = $promocode_value;






    }
 
    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $subject = "New Order #{$this->order_id} placed - Shevings";

        return $this->from('your-email@example.com', $this->fromEmail)
                    ->subject($subject)
                    ->view('emails.submittedordermail')
                    ->with([
                        'fromEmail'                 => $this->fromEmail,
                        'toEmail'                   => $this->toEmail,
                        'order_id'                  => $this->order_id,
                        'customer_name'             => $this->customer_name,
                        'extractedCardDetails'      => $this->extractedCardDetails, 
                        'order_status'              => $this->order_status, 
                        'delivery_charge'           => $this->delivery_charge, 
                        'over_all_total'            => $this->over_all_total, 
                        'deliveryDetails'           => $this->deliveryDetails, 
                        'order_description'         => $this->order_description,
                        'total_amount'              => $this->total_amount,
                        'promocode_value'           => $this->promocode_value,

                    ])
                    ->cc($this->ccEmails); // Use cc to set CC recipients

    }
}
