update email template
This commit is contained in:
@@ -17,6 +17,7 @@ class DnsDomain extends Model
|
||||
'dns_manager_server_id',
|
||||
'is_created',
|
||||
'plesk_id',
|
||||
'registrar_id',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
@@ -24,6 +25,11 @@ class DnsDomain extends Model
|
||||
return $this->belongsToMany(Customer::class, 'dns_domain_user', 'domain_id', 'user_id')->withTimestamps();
|
||||
}
|
||||
|
||||
public function registrar()
|
||||
{
|
||||
return $this->belongsTo(Registrar::class);
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->customer();
|
||||
|
||||
@@ -22,6 +22,8 @@ class ModuleDomain extends Model
|
||||
'next_invoice_date',
|
||||
'customer_id',
|
||||
'domain_type_id',
|
||||
'registrar_id',
|
||||
'note',
|
||||
'status'
|
||||
];
|
||||
|
||||
@@ -29,4 +31,9 @@ class ModuleDomain extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Customer::class);
|
||||
}
|
||||
|
||||
public function registrar()
|
||||
{
|
||||
return $this->belongsTo(Registrar::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ class Order extends Model
|
||||
|
||||
protected $casts = [
|
||||
'date' => 'date',
|
||||
'paid_at' => 'datetime',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
@@ -41,12 +42,18 @@ class Order extends Model
|
||||
return $this->hasMany(OrderItem::class, 'order_id');
|
||||
}
|
||||
|
||||
/** Invoice generated from this order. */
|
||||
/** First/primary invoice generated from this order (kept for backward compat — an order can have many). */
|
||||
public function invoice()
|
||||
{
|
||||
return $this->hasOne(Invoice::class, 'order_id');
|
||||
}
|
||||
|
||||
/** All invoices billed against this order (initial + renewals) — an order can have many. */
|
||||
public function invoices()
|
||||
{
|
||||
return $this->hasMany(Invoice::class, 'order_id');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@@ -20,6 +20,11 @@ class ProductCategories extends Model
|
||||
'is_active',
|
||||
'sort_order',
|
||||
'type',
|
||||
'billing_cycles',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'billing_cycles' => 'array',
|
||||
];
|
||||
|
||||
public function parent()
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Registrar extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'registrars';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'short_name',
|
||||
'status',
|
||||
'website',
|
||||
];
|
||||
|
||||
public function domains()
|
||||
{
|
||||
return $this->hasMany(ModuleDomain::class, 'registrar_id');
|
||||
}
|
||||
}
|
||||
+69
-5
@@ -4,11 +4,14 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class Template extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public const CACHE_PREFIX = 'email_template:';
|
||||
|
||||
protected $table = 'template';
|
||||
|
||||
protected $fillable = [
|
||||
@@ -19,18 +22,79 @@ class Template extends Model
|
||||
'name',
|
||||
'subject',
|
||||
'message',
|
||||
'metadata',
|
||||
'builder_data',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'status' => 'integer',
|
||||
'status' => 'integer',
|
||||
'metadata' => 'array',
|
||||
'builder_data' => 'array',
|
||||
];
|
||||
|
||||
protected static function booted(): void
|
||||
{
|
||||
static::saved(fn (self $template) => $template->forgetCache());
|
||||
static::deleted(fn (self $template) => $template->forgetCache());
|
||||
}
|
||||
|
||||
public function forgetCache(): void
|
||||
{
|
||||
if ($this->scenario) {
|
||||
Cache::forget(self::CACHE_PREFIX . $this->scenario);
|
||||
}
|
||||
}
|
||||
|
||||
/** Danh sách variable hợp lệ khai báo trong metadata.variables, key theo variable key. */
|
||||
public function variables(): array
|
||||
{
|
||||
return collect($this->metadata['variables'] ?? [])->keyBy('key')->all();
|
||||
}
|
||||
|
||||
/** Mail sender config khai báo trong metadata.mail (from_email, from_name, reply_to, reply_to_name, cc, bcc). */
|
||||
public function mailConfig(): array
|
||||
{
|
||||
return $this->metadata['mail'] ?? [];
|
||||
}
|
||||
|
||||
public const SCENARIOS = [
|
||||
'vm_credentials' => 'Khởi tạo dịch vụ',
|
||||
'renewal_reminder' => 'Nhắc gia hạn',
|
||||
'news_notification'=> 'Thông báo tin tức',
|
||||
'invoice_pdf' => 'Hoá đơn điện tử',
|
||||
'vm_credentials' => 'Khởi tạo dịch vụ',
|
||||
'renewal_reminder' => 'Nhắc gia hạn',
|
||||
'news_notification' => 'Thông báo tin tức',
|
||||
'invoice_pdf' => 'Hoá đơn điện tử',
|
||||
'vm_suspended' => 'VPS bị tạm ngưng',
|
||||
'domain_order_received' => 'Đơn đăng ký tên miền đã ghi nhận',
|
||||
'hosting_account_created' => 'Hosting đã khởi tạo',
|
||||
'manual_deposit_status' => 'Trạng thái nạp tiền thủ công',
|
||||
'order_payment_success' => 'Thanh toán đơn hàng thành công',
|
||||
'password_reset_admin' => 'Admin cấp lại mật khẩu',
|
||||
'service_renewal_reminder'=> 'Nhắc gia hạn dịch vụ',
|
||||
'snapshot_action' => 'Thao tác Snapshot VPS',
|
||||
'ticket_created' => 'Ticket hỗ trợ mới',
|
||||
'verify_account_welcome' => 'Mã xác thực tài khoản',
|
||||
'vm_creation_failed' => 'Khởi tạo VPS thất bại',
|
||||
'vm_password_changed' => 'Đổi mật khẩu VPS',
|
||||
'vm_rebuild_failed' => 'Rebuild VPS thất bại',
|
||||
'holiday_notice' => 'Thông báo nghỉ lễ',
|
||||
'domain_order_approved' => 'Tên miền được duyệt',
|
||||
'domain_order_rejected' => 'Tên miền bị từ chối',
|
||||
'order_created' => 'Xác nhận đơn hàng',
|
||||
'admin_order_notification' => '[Admin] Đơn hàng mới',
|
||||
'admin_domain_order_new' => '[Admin] Đơn đăng ký tên miền mới',
|
||||
'admin_hosting_account_created' => '[Admin] Hosting account mới',
|
||||
'admin_manual_deposit_pending' => '[Admin] Yêu cầu nạp tiền chờ duyệt',
|
||||
'admin_ticket_notification' => '[Admin] Ticket hỗ trợ mới',
|
||||
'admin_trial_registration_request' => '[Admin] Yêu cầu dùng thử VPS',
|
||||
'customer_deposit_success' => 'Nạp tiền thành công',
|
||||
'customer_welcome' => 'Chào mừng khách hàng mới',
|
||||
'vm_port_change' => 'Đổi port Remote VPS',
|
||||
'vm_password_reset_success' => 'Đặt lại mật khẩu VPS thành công',
|
||||
'customer_signup_verify' => 'Xác thực đăng ký tài khoản',
|
||||
'hosting_information' => 'Thông tin truy cập Hosting',
|
||||
'customer_password_reset' => 'Khôi phục mật khẩu khách hàng',
|
||||
'service_expiry' => 'Dịch vụ sắp hết hạn',
|
||||
'customer_payment' => 'Thông báo thanh toán khách hàng',
|
||||
];
|
||||
|
||||
public function invoiceTemplate()
|
||||
|
||||
+3
-8
@@ -23,9 +23,8 @@ class User extends Authenticatable implements JWTSubject
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $fillable = [
|
||||
'firstname',
|
||||
'fullname',
|
||||
'password',
|
||||
'lastname',
|
||||
'username',
|
||||
'email',
|
||||
'email_verified_at',
|
||||
@@ -41,10 +40,7 @@ class User extends Authenticatable implements JWTSubject
|
||||
*
|
||||
* @var array<int, string>
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password',
|
||||
'remember_token',
|
||||
];
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast.
|
||||
@@ -53,7 +49,7 @@ class User extends Authenticatable implements JWTSubject
|
||||
*/
|
||||
protected $casts = [
|
||||
'email_verified_at' => 'datetime',
|
||||
'start_date' => 'date',
|
||||
'start_date' => 'date',
|
||||
];
|
||||
|
||||
public function getJWTIdentifier()
|
||||
@@ -75,5 +71,4 @@ class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
return $this->hasOne(\App\Models\Staff::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user