57 lines
1.7 KiB
PHP
57 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Notifications;
|
|
|
|
use App\Models\Consultation;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
use Illuminate\Notifications\Notification;
|
|
|
|
/**
|
|
* Emails the business development inbox when a consultation request arrives.
|
|
*/
|
|
class NewConsultationRequest extends Notification implements ShouldQueue
|
|
{
|
|
use Queueable;
|
|
|
|
public function __construct(public Consultation $consultation) {}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public function via(object $notifiable): array
|
|
{
|
|
return ['mail'];
|
|
}
|
|
|
|
public function toMail(object $notifiable): MailMessage
|
|
{
|
|
$consultation = $this->consultation;
|
|
|
|
$message = (new MailMessage)
|
|
->subject("Permintaan konsultasi baru: {$consultation->name}")
|
|
->greeting('Permintaan konsultasi baru')
|
|
->line("Nama: {$consultation->name}")
|
|
->line("Email: {$consultation->email}")
|
|
->line("Telepon: {$consultation->phone}");
|
|
|
|
foreach ([
|
|
'Perusahaan' => $consultation->company,
|
|
'Jabatan' => $consultation->job_title,
|
|
'Sektor' => $consultation->industry,
|
|
'Layanan' => $consultation->service,
|
|
'Linimasa' => $consultation->timeline,
|
|
'Kebutuhan' => $consultation->details,
|
|
] as $label => $value) {
|
|
if ($value) {
|
|
$message->line("{$label}: {$value}");
|
|
}
|
|
}
|
|
|
|
return $message
|
|
->replyTo($consultation->email, $consultation->name)
|
|
->action('Buka Inbox Konsultasi', route('admin.consultations.index'));
|
|
}
|
|
}
|