feat(email-blast): perbarui tampilan dan logika pengiriman email blast
- Tambahkan pengambilan data penerima dari model Customer. - Modifikasi konstruktor EmailBlastMail untuk menerima objek penerima. - Perbarui tampilan email blast untuk menampilkan subjek dan nama penerima. - Tambahkan styling baru untuk tampilan email agar lebih menarik.
This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
|||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
use Illuminate\Queue\SerializesModels;
|
use Illuminate\Queue\SerializesModels;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
use Modules\Webstatement\Models\Customer;
|
||||||
use Modules\Webstatement\Models\EmailBlastHistory;
|
use Modules\Webstatement\Models\EmailBlastHistory;
|
||||||
use Modules\Webstatement\Mail\EmailBlastMail;
|
use Modules\Webstatement\Mail\EmailBlastMail;
|
||||||
|
|
||||||
@@ -27,9 +28,11 @@ class SendEmailBlast implements ShouldQueue
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
foreach ($this->recipients as $recipient) {
|
foreach ($this->recipients as $recipient) {
|
||||||
Mail::to($recipient)->send(new EmailBlastMail($this->emailBlastHistory));
|
$_receipent = Customer::where('email', $recipient)->first();
|
||||||
|
Mail::to($recipient)->send(new EmailBlastMail($this->emailBlastHistory, $_receipent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->emailBlastHistory->update(['status' => 'completed']);
|
$this->emailBlastHistory->update(['status' => 'completed']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,10 +12,12 @@ class EmailBlastMail extends Mailable
|
|||||||
use Queueable, SerializesModels;
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
public $emailBlastHistory;
|
public $emailBlastHistory;
|
||||||
|
public $recipient;
|
||||||
|
|
||||||
public function __construct(EmailBlastHistory $emailBlastHistory)
|
public function __construct(EmailBlastHistory $emailBlastHistory, $recipient)
|
||||||
{
|
{
|
||||||
$this->emailBlastHistory = $emailBlastHistory;
|
$this->emailBlastHistory = $emailBlastHistory;
|
||||||
|
$this->recipient = $recipient;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build()
|
public function build()
|
||||||
@@ -23,7 +25,9 @@ class EmailBlastMail extends Mailable
|
|||||||
return $this->subject($this->emailBlastHistory->subject)
|
return $this->subject($this->emailBlastHistory->subject)
|
||||||
->view('webstatement::emails.blast')
|
->view('webstatement::emails.blast')
|
||||||
->with([
|
->with([
|
||||||
'content' => $this->emailBlastHistory->content
|
'content' => $this->emailBlastHistory->content,
|
||||||
|
'subject' => $this->emailBlastHistory->subject,
|
||||||
|
'recipient' => $this->recipient->name,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,22 +3,69 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Email Blast</title>
|
<title>{{ $subject }}</title>
|
||||||
<style>
|
<style>
|
||||||
body{
|
body {
|
||||||
font-family: monospace;
|
font-family: 'Arial', sans-serif;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #333;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: #f4f4f4;
|
||||||
}
|
}
|
||||||
|
.container {
|
||||||
.ql-align-center{
|
max-width: 600px;
|
||||||
|
margin: 20px auto;
|
||||||
|
background-color: #ffffff;
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
box-shadow: 0 0 10px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
background-color: #35c1d080;
|
||||||
|
color: #ffffff;
|
||||||
|
padding: 20px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.ql-align-right{
|
.header h1 {
|
||||||
text-align: right;
|
margin: 0;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
.content {
|
||||||
|
padding: 30px;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
background-color: #35c1d080;
|
||||||
|
padding: 15px;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
.btn {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #0056b3;
|
||||||
|
color: #ffffff;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
{!! $content !!}
|
<div class="container">
|
||||||
|
<div class="header">
|
||||||
|
<h1>{{ $subject }}</h1>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
<p>Halo {{ $recipient->name }},</p>
|
||||||
|
|
||||||
|
{!! $content !!}
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p>© 2023 Bank Artha Graha Internasional. All rights reserved.</p>
|
||||||
|
<p>Jika Anda memiliki pertanyaan, silakan hubungi customer service kami.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user