feat: add domain registration form and email notifications

- Create a new Blade view for domain registration (`registrant-tochuc.blade.php`) to capture organization and manager details.
- Implement email templates for new domain orders for both admin (`domain-order-new.blade.php`) and customers (`domain-order-received.blade.php`).
- Add CSV exports for client and domain data.
- Introduce tests for customer mass assignment, password reset, login throttling, and permission gating.
- Ensure service renewals use current pricing and validate ownership for virtual machines.
- Validate mass assignment behavior in service model.
This commit is contained in:
baodev0
2026-08-22 17:30:55 +07:00
parent eec2c5906e
commit c377c7e195
58 changed files with 3063 additions and 418 deletions
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('user', function (Blueprint $table) {
$table->string('department')->nullable()->after('address');
$table->date('start_date')->nullable()->after('department');
});
}
public function down(): void
{
Schema::table('user', function (Blueprint $table) {
$table->dropColumn(['department', 'start_date']);
});
}
};
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::create('export_jobs', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('type', 30);
$table->string('format', 10);
$table->json('filters')->nullable();
$table->json('fields')->nullable();
$table->string('status', 20)->default('completed');
$table->string('file_path')->nullable();
$table->unsignedInteger('total_rows')->nullable();
$table->text('error')->nullable();
$table->bigInteger('created_by')->nullable()->index();
$table->timestamp('completed_at')->nullable();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('export_jobs');
}
};
@@ -0,0 +1,128 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('domain_pricings', function (Blueprint $table) {
$table->id();
$table->enum('type', ['domain', 'service'])->default('domain');
$table->string('tld')->nullable(); // domain rows, e.g. ".com.vn"
$table->string('name')->nullable(); // service rows, e.g. "Chứng thực Rapid SSL"
$table->string('setup_fee')->default('Miễn phí'); // "Miễn phí" or a numeric string
$table->unsignedBigInteger('first_year')->nullable(); // domain only
$table->string('recurring_fee')->nullable(); // domain: renewal (numeric). service: maintenance ("Miễn phí" or numeric)
$table->text('note')->nullable(); // service only
$table->unsignedInteger('sort_order')->default(0);
$table->boolean('is_active')->default(true);
$table->timestamps();
});
$this->seedFromExistingSetting();
}
/**
* Carry over whatever is in the `domain_pricing` Setting (admin-customized
* or the built-in defaults) so switching storage doesn't lose data.
*/
private function seedFromExistingSetting(): void
{
$setting = DB::table('setting')->where('key', 'domain_pricing')->first();
$value = $setting ? json_decode((string) $setting->value, true) : null;
if (!is_array($value) || empty($value)) {
$value = $this->defaultData();
}
$now = now();
$rows = [];
foreach (($value['domains'] ?? []) as $i => $d) {
$rows[] = [
'type' => 'domain',
'tld' => $d['tld'] ?? null,
'name' => null,
'setup_fee' => (string) ($d['setupFee'] ?? 'Miễn phí'),
'first_year' => $d['firstYear'] ?? 0,
'recurring_fee' => (string) ($d['renewal'] ?? 0),
'note' => null,
'sort_order' => $i,
'is_active' => true,
'created_at' => $now,
'updated_at' => $now,
];
}
foreach (($value['services'] ?? []) as $i => $s) {
$rows[] = [
'type' => 'service',
'tld' => null,
'name' => $s['name'] ?? null,
'setup_fee' => (string) ($s['setupFee'] ?? 'Miễn phí'),
'first_year' => null,
'recurring_fee' => (string) ($s['maintenance'] ?? 'Miễn phí'),
'note' => $s['note'] ?? null,
'sort_order' => $i,
'is_active' => true,
'created_at' => $now,
'updated_at' => $now,
];
}
if (!empty($rows)) {
DB::table('domain_pricings')->insert($rows);
}
}
private function defaultData(): array
{
return [
'domains' => [
['tld' => '.vn', 'setupFee' => 'Miễn phí', 'firstYear' => 400000, 'renewal' => 400000],
['tld' => '.com.vn', 'setupFee' => 'Miễn phí', 'firstYear' => 300000, 'renewal' => 300000],
['tld' => '.net.vn', 'setupFee' => 'Miễn phí', 'firstYear' => 300000, 'renewal' => 300000],
['tld' => '.org.vn', 'setupFee' => 'Miễn phí', 'firstYear' => 300000, 'renewal' => 300000],
['tld' => '.com', 'setupFee' => 'Miễn phí', 'firstYear' => 320000, 'renewal' => 340000],
['tld' => '.net', 'setupFee' => 'Miễn phí', 'firstYear' => 369000, 'renewal' => 409000],
['tld' => '.org', 'setupFee' => 'Miễn phí', 'firstYear' => 339000, 'renewal' => 369000],
['tld' => '.biz', 'setupFee' => 'Miễn phí', 'firstYear' => 399000, 'renewal' => 409000],
['tld' => '.info', 'setupFee' => 'Miễn phí', 'firstYear' => 490000, 'renewal' => 509000],
['tld' => '.pro', 'setupFee' => 'Miễn phí', 'firstYear' => 469000, 'renewal' => 489000],
['tld' => '.name', 'setupFee' => 'Miễn phí', 'firstYear' => 259000, 'renewal' => 259000],
['tld' => '.ws', 'setupFee' => 'Miễn phí', 'firstYear' => 909000, 'renewal' => 909000],
['tld' => '.tv', 'setupFee' => 'Miễn phí', 'firstYear' => 765000, 'renewal' => 819000],
['tld' => '.mobi', 'setupFee' => 'Miễn phí', 'firstYear' => 589000, 'renewal' => 589000],
['tld' => '.uk', 'setupFee' => 'Miễn phí', 'firstYear' => 537000, 'renewal' => 537000],
['tld' => '.asia', 'setupFee' => 'Miễn phí', 'firstYear' => 380000, 'renewal' => 452000],
['tld' => '.me', 'setupFee' => 'Miễn phí', 'firstYear' => 1029000, 'renewal' => 1029000],
['tld' => '.us', 'setupFee' => 'Miễn phí', 'firstYear' => 323000, 'renewal' => 323000],
],
'services' => [
['name' => 'Chứng thực Rapid SSL', 'setupFee' => 230000, 'maintenance' => 750000, 'note' => '01 Domain'],
['name' => 'Chứng thực Quick SSL', 'setupFee' => 230000, 'maintenance' => 2300000, 'note' => '01 Domain'],
['name' => 'Chứng thực Wildcard SSL', 'setupFee' => 230000, 'maintenance' => 3300000, 'note' => 'Unlimited Subdomain'],
['name' => 'Chứng thực True BusinessID', 'setupFee' => 540000, 'maintenance' => 3900000, 'note' => '01 Domain'],
['name' => 'Chứng thực True BusinessID WildCard', 'setupFee' => 900000, 'maintenance' => 15000000, 'note' => 'Unlimited Subdomain'],
['name' => 'Đăng ký DNS riêng', 'setupFee' => 200000, 'maintenance' => 'Miễn phí', 'note' => "dns1.tenmiencuaban.com\ndns2.tenmiencuaban.com"],
['name' => 'Bảo mật thông tin tên miền', 'setupFee' => 'Miễn phí', 'maintenance' => 90000, 'note' => 'Toàn bộ thông tin Whois tên miền của bạn sẽ được giấu kín hoàn toàn với mọi công cụ Whois'],
['name' => 'Khóa tên miền', 'setupFee' => 'Miễn phí', 'maintenance' => 'Miễn phí', 'note' => 'Tăng cường bảo mật cho tên miền'],
],
];
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('domain_pricings');
}
};
@@ -0,0 +1,23 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('services', function (Blueprint $table) {
$table->string('registrant_type', 20)->nullable()->after('rejection_reason');
$table->json('registrant_info')->nullable()->after('registrant_type');
});
}
public function down(): void
{
Schema::table('services', function (Blueprint $table) {
$table->dropColumn(['registrant_type', 'registrant_info']);
});
}
};