<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Settings as mSetting;

class CheckoutNotifBuyer extends Mailable
{
    use Queueable, SerializesModels;

    public $form_data;
    public $cart;

    /**
     * Create a new message instance.
     *
     * @return void
     */
     public function __construct($form_data = null,$cart = null)
     {
         $this->form_data = $form_data;
         $this->cart = $cart;
     }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        $companyName = mSetting::where(['setting_name'=>'companyName'])->first()->setting_value;
        $email = mSetting::where(['setting_name'=>'companyEmail'])->first()->setting_value;

        if($this->form_data['to'] == "buyer"){
          return $this->markdown('emails.orders.notif_buyer')
                  ->from($email)
                  ->subject('Order Detail '.date('d/m/Y'));
        }else{
          return $this->markdown('emails.orders.notif_buyer')
                  ->from($email)
                  ->subject('New Order '.date('d/m/Y'));
        }

    }
}
