42 lines
1.6 KiB
PHP
42 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace IriksIT\Manager\Mail;
|
|
|
|
use Illuminate\Mail\Mailable;
|
|
use Illuminate\Mail\Mailables\Address;
|
|
use Illuminate\Mail\Mailables\Content;
|
|
use Illuminate\Mail\Mailables\Envelope;
|
|
use IriksIT\Manager\Models\Lead;
|
|
use IriksIT\Manager\Support\Leads\Phone;
|
|
|
|
/**
|
|
* Tells the owner about a new request with the same three buttons as the manager: call, WhatsApp, mail. Sent by the site from its own
|
|
* address; the visitor is the Reply-To, never the sender (that fails the checks of mail providers). The view `manager::mail.lead-received`
|
|
* can be replaced by a site (resources/views/vendor/manager/mail/lead-received.blade.php).
|
|
*/
|
|
class LeadReceived extends Mailable
|
|
{
|
|
public function __construct(public Lead $lead) {}
|
|
|
|
public function envelope(): Envelope
|
|
{
|
|
return new Envelope(
|
|
subject: $this->lead->kindLabel().' — '.$this->lead->name.($this->lead->subject ? ': '.$this->lead->subject : ''),
|
|
replyTo: $this->lead->email ? [new Address($this->lead->email, $this->lead->name)] : [],
|
|
);
|
|
}
|
|
|
|
public function content(): Content
|
|
{
|
|
$digits = $this->lead->phone ? Phone::international($this->lead->phone) : null;
|
|
|
|
return new Content(view: 'manager::mail.lead-received', with: [
|
|
'lead' => $this->lead,
|
|
'callLink' => $digits ? 'tel:+'.$digits : null,
|
|
'whatsappLink' => $digits ? 'https://wa.me/'.$digits : null,
|
|
'mailLink' => $this->lead->email ? 'mailto:'.$this->lead->email : null,
|
|
'managerLink' => url(config('manager.path').'/leads').'?open='.$this->lead->id,
|
|
]);
|
|
}
|
|
}
|