osb/app/Mail/OrderRequestApprove.php

58 lines
1.2 KiB
PHP

<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Config;
use App\Models\Service;
class OrderRequestApprove extends Mailable
{
use Queueable, SerializesModels;
public Service $so;
public string $notes;
/**
* Create a new message instance.
*
* @param Service $o
* @param string $notes
*/
public function __construct(Service $o,string $notes='')
{
$this->so = $o;
$this->notes = $notes;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
Config::set('site',$this->so->site);
// @todo This is not consistent with Cancel/Change Request
switch ($this->so->product->category) {
case 'broadband': $subject = sprintf('%s: %s',$this->so->product->category,$this->so->type->service_address);
break;
case 'phone': $subject = sprintf('%s: %s',$this->so->product->category,$this->so->type->service_number);
break;
default:
$subject = 'New Order Request';
}
return $this
->markdown('mail.admin.order.approve')
->subject($subject)
->with(['site'=>$this->so->site]);
}
}