<?php

namespace App\Mail;

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

class Message extends Mailable
{
    use Queueable, SerializesModels;
	
	public $subject;
	public $description;
	public $company;
	public $files;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($subject, $description, $attachments)
    {
		
		$this->subject = $subject;
        $this->description = $description;
		$this->company = \Auth::user()->employee->company;
		$this->files = $attachments;
		
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
		
		$message = $this->from($this->company->contacts['email'], $this->company->name)->subject($this->subject)->view('emails.message');	
		
		if (count($this->files)) {
			foreach ($this->files as $file) {
				$message->attach($file['url']);
			}
		}
		
		return $message;
		
    }
}
