update vm ticket

This commit is contained in:
baodev0
2026-07-14 17:03:38 +07:00
parent f035730a44
commit 401dcc8783
24 changed files with 950 additions and 31 deletions
@@ -0,0 +1,34 @@
<?php
namespace App\Mail\Admin;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class TicketAdminNotification extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public function __construct(
public readonly mixed $ticket,
public readonly mixed $customer,
) {}
public function build(): static
{
return $this
->subject("[ADMIN] Ticket mới #{$this->ticket->ticket_num} — {$this->customer->email}")
->view('emails.admin.ticket-notification')
->with([
'ticketNum' => $this->ticket->ticket_num,
'subject' => $this->ticket->subject,
'room' => $this->ticket->room,
'description' => strip_tags($this->ticket->description),
'customerName' => trim($this->customer->firstname . ' ' . $this->customer->lastname),
'customerEmail' => $this->customer->email,
'ticketUrl' => config('app.frontend_url') . '/tickets/' . $this->ticket->ticket_num,
]);
}
}
+65
View File
@@ -0,0 +1,65 @@
<?php
namespace App\Mail\Customer;
use App\Models\Setting;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class VmPasswordChanged extends Mailable
{
use Queueable, SerializesModels;
public function __construct(public array $data) {}
public function envelope(): Envelope
{
$appName = $this->payload()['company_name'] ?? config('app.name', 'The Gioi So');
return new Envelope(
subject: 'Mật khẩu VM của bạn đã được thay đổi — ' . $appName,
);
}
public function content(): Content
{
$data = $this->payload();
return new Content(
view: 'emails.customer.vm-password-changed',
with: [
'appName' => $data['company_name'] ?? config('app.name', 'The Gioi So'),
'fullName' => $data['fullname'] ?? 'Quý khách',
'vmName' => $data['vm_name'] ?? '',
'loginUrl' => $data['login_url'] ?? rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap',
'supportEmail' => $data['support_email'] ?? config('mail.support_email', 'support@thegioiso.com'),
'supportPhone' => $data['support_phone'] ?? config('mail.support_phone', '1900.xxxx'),
],
);
}
public function attachments(): array
{
return [];
}
private function payload(): array
{
try {
$setting = Setting::where('key', 'setting')->first();
$settingValue = $setting ? json_decode((string) $setting->value, true) : [];
} catch (\Throwable) {
$settingValue = [];
}
return array_merge([
'company_name' => $settingValue['company'] ?? config('app.name', 'The Gioi So'),
'support_email' => $settingValue['email'] ?? config('mail.support_email', 'support@thegioiso.com'),
'support_phone' => $settingValue['hotline'] ?? ($settingValue['phone'] ?? config('mail.support_phone', '1900.xxxx')),
'login_url' => rtrim(config('app.frontend_url', ''), '/') . '/dang-nhap',
], $this->data);
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class TicketCreated extends Mailable implements ShouldQueue
{
use Queueable, SerializesModels;
public function __construct(
public readonly mixed $ticket,
public readonly mixed $customer,
) {}
public function envelope(): Envelope
{
return new Envelope(
subject: "[#{$this->ticket->ticket_num}] Yêu cầu hỗ trợ của bạn đã được tiếp nhận",
);
}
public function content(): Content
{
return new Content(
view: 'emails.customer.ticket-created',
with: [
'fullName' => trim("{$this->customer->firstname} {$this->customer->lastname}") ?: 'Quý khách',
'ticketNum' => $this->ticket->ticket_num,
'subject' => $this->ticket->subject,
'room' => $this->ticket->room,
'ticketUrl' => rtrim(config('app.frontend_url', ''), '/') . '/tickets/' . $this->ticket->ticket_num,
],
);
}
public function attachments(): array
{
return [];
}
}