update
This commit is contained in:
@@ -263,17 +263,6 @@ HTML
|
||||
'type_id' => 0,
|
||||
'status' => 1,
|
||||
],
|
||||
[
|
||||
'name' => 'Thông báo nghỉ lễ',
|
||||
'scenario' => 'holiday_notice',
|
||||
'format' => 'html',
|
||||
'subject' => 'Thông báo lịch nghỉ lễ từ {$holiday_name}',
|
||||
'message' => <<<'HTML'
|
||||
<table style="border-collapse: collapse; width: 100%; background-color: #efefef;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding: 20px;" align="center" valign="top"><table style="padding-top: 20px; padding-bottom: 20px; border-collapse: collapse; background-color: #ffffff; width: 700px;" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td style="width: 700px;" valign="top"><img style="display: block; border: 0;" src="{$hero_image}" alt="" width="700" height="350"><div style="padding: 0 30px; font-family: Arial, Helvetica, sans-serif; font-size: 14px; line-height: 1.6; color: #000000;"><div> </div><div><strong>Kính gửi: Quý Khách hàng, Quý Đối tác</strong></div><div> </div><div>Nhân dịp kỷ niệm <strong>{$holiday_name}</strong>, Thế Giới Số xin trân trọng gửi tới Quý Khách hàng và Quý Đối tác lời chúc sức khỏe, hạnh phúc và thành công.</div><div> </div><div><strong>Thế Giới Số</strong> xin thông báo lịch nghỉ lễ như sau:</div><div> <strong>Thời gian nghỉ lễ:</strong> Từ <strong>{$holiday_from}</strong> đến hết <strong>{$holiday_to}</strong></div><div> <strong>Thời gian làm việc trở lại:</strong> <strong>{$work_again}</strong></div><div> </div><div>Trong thời gian nghỉ lễ, nếu có vấn đề cần hỗ trợ kỹ thuật vui lòng liên hệ:</div><div> + Gửi ticket qua: <a href="{$ticket_url}" target="_blank" rel="noopener">{$ticket_url}</a></div><div> + Email: <a href="mailto:{$support_email}">{$support_email}</a></div><div> + Hotline: <strong>{$hotline}</strong></div><div> </div><div>Kính chúc Quý Khách hàng và Quý Đối tác có một kỳ nghỉ lễ vui vẻ, an toàn và nhiều sức khỏe.</div><div> </div></div></td></tr></tbody></table></td></tr></tbody></table>
|
||||
HTML,
|
||||
'type_id' => 0,
|
||||
'status' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($newTemplates as $item) {
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\Customer;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* Tài khoản dùng để kiểm thử luồng order/invoice sau đợt sửa.
|
||||
* Chạy: php artisan db:seed --class=TestAccountSeeder
|
||||
*
|
||||
* Idempotent — chạy lại chỉ đặt lại mật khẩu, không tạo trùng.
|
||||
*/
|
||||
class TestAccountSeeder extends Seeder
|
||||
{
|
||||
private const CUSTOMER_EMAIL = 'pbao.dev@gmail.com';
|
||||
private const CUSTOMER_PASSWORD = 'password123';
|
||||
private const ADMIN_USERNAME = 'admin';
|
||||
private const ADMIN_PASSWORD = '!admin@123!@#';
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$this->seedAdmin();
|
||||
$this->seedCustomer();
|
||||
}
|
||||
|
||||
private function seedAdmin(): void
|
||||
{
|
||||
$admin = User::where('username', self::ADMIN_USERNAME)->first();
|
||||
|
||||
if ($admin) {
|
||||
$admin->update(['password' => Hash::make(self::ADMIN_PASSWORD)]);
|
||||
$this->command?->info('Admin đã có — đặt lại mật khẩu cho "' . self::ADMIN_USERNAME . '".');
|
||||
} else {
|
||||
$admin = User::create([
|
||||
'fullname' => 'System Admin',
|
||||
'username' => self::ADMIN_USERNAME,
|
||||
'email' => 'admin@tgs.com.vn',
|
||||
'email_verified_at' => now(),
|
||||
'password' => Hash::make(self::ADMIN_PASSWORD),
|
||||
]);
|
||||
$this->command?->info('Đã tạo admin "' . self::ADMIN_USERNAME . '".');
|
||||
}
|
||||
|
||||
// status nằm ngoài $fillable nên phải gán thẳng.
|
||||
$admin->forceFill(['status' => 1])->save();
|
||||
|
||||
if (method_exists($admin, 'syncRoles') && \Spatie\Permission\Models\Role::where('name', 'Full Administrator')->exists()) {
|
||||
$admin->syncRoles(['Full Administrator']);
|
||||
$this->command?->info(' → gán role Full Administrator.');
|
||||
}
|
||||
}
|
||||
|
||||
private function seedCustomer(): void
|
||||
{
|
||||
$customer = Customer::where('email', self::CUSTOMER_EMAIL)->first();
|
||||
|
||||
if ($customer) {
|
||||
$customer->update(['password' => Hash::make(self::CUSTOMER_PASSWORD)]);
|
||||
$this->command?->info('Khách hàng đã có — đặt lại mật khẩu cho ' . self::CUSTOMER_EMAIL . '.');
|
||||
} else {
|
||||
$customer = Customer::create([
|
||||
'fullname' => 'Phạm Bảo (test)',
|
||||
'username' => 'pbao.dev',
|
||||
'email' => self::CUSTOMER_EMAIL,
|
||||
'phone' => '0900000000',
|
||||
'password' => Hash::make(self::CUSTOMER_PASSWORD),
|
||||
'email_verified_at' => now(),
|
||||
'email_verify' => 1,
|
||||
'address' => '128/38 Tân Hương, Phú Thọ Hòa, TP. Hồ Chí Minh',
|
||||
]);
|
||||
$this->command?->info('Đã tạo khách hàng ' . self::CUSTOMER_EMAIL . '.');
|
||||
}
|
||||
|
||||
// Nạp sẵn số dư để đặt và thanh toán đơn thử, kể cả các ca trả từng phần.
|
||||
$customer->forceFill([
|
||||
'status' => 1,
|
||||
'total' => max((int) $customer->total, 50_000_000),
|
||||
])->save();
|
||||
|
||||
if (empty($customer->uuid)) {
|
||||
$customer->forceFill(['uuid' => (string) Str::uuid()])->save();
|
||||
}
|
||||
|
||||
$this->command?->info(' → số dư: ' . number_format((int) $customer->fresh()->total) . ' VNĐ');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user