osb/app/Mail/CancelRequest.php

61 lines
1.2 KiB
PHP
Raw Normal View History

2021-09-29 04:57:25 +00:00
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Config;
2021-09-29 04:57:25 +00:00
use App\Models\Service;
class CancelRequest extends Mailable
{
use Queueable, SerializesModels;
public Service $service;
public ?string $notes;
2021-09-29 04:57:25 +00:00
/**
* Create a new message instance.
*
* @param Service $o
* @param string|NULL $notes
2021-09-29 04:57:25 +00:00
*/
public function __construct(Service $o,string $notes=NULL)
2021-09-29 04:57:25 +00:00
{
$this->service = $o;
$this->notes = $notes;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
Config::set('site',$this->service->site);
2021-09-29 04:57:25 +00:00
switch (get_class($this->service->type)) {
case Service\Broadband::class:
$subject = sprintf('Cancel BROADBAND: %s (%s)',
$this->service->type->service_number,
$this->service->type->service_address);
2021-09-29 04:57:25 +00:00
break;
case Service\Phone::class:
2022-04-19 07:07:39 +00:00
$subject = sprintf('Cancel PHONE: %s',$this->service->type->service_number);
2021-09-29 04:57:25 +00:00
break;
default:
$subject = 'Cancel Service Request';
}
return $this
->markdown('mail.admin.service.cancel')
2021-09-29 04:57:25 +00:00
->subject($subject)
->with(['site'=>$this->service->site]);
}
}