feat: Implement Plesk domain and hosting services
- Added PleskDomainService for managing domain operations (create, update, remove, get info). - Introduced PleskHostingService for provisioning hosting accounts and notifying customers. - Created PleskService for handling API requests to Plesk. - Added migration to include 'type' column in dns_manager_servers table. - Created migration for module_hosting_accounts table to track hosting subscriptions. - Created migration for module_hosting_plesk_clients table to manage Plesk client credentials. - Added email templates for notifying customers and admins about hosting account creation.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('dns_manager_servers', function (Blueprint $table) {
|
||||
$table->string('type', 20)->default('domain')->after('status');
|
||||
});
|
||||
|
||||
// every existing server already serves DNS today
|
||||
DB::table('dns_manager_servers')->update(['type' => 'domain']);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('dns_manager_servers', function (Blueprint $table) {
|
||||
$table->dropColumn('type');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,44 @@
|
||||
<?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('module_hosting_accounts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('customer_id')->index();
|
||||
$table->unsignedBigInteger('service_id')->nullable()->index();
|
||||
$table->unsignedBigInteger('dns_manager_server_id')->index();
|
||||
$table->unsignedBigInteger('dns_manager_domain_id')->nullable()->index();
|
||||
|
||||
$table->unsignedInteger('plesk_client_id')->nullable();
|
||||
$table->unsignedInteger('plesk_subscription_id')->nullable()->index();
|
||||
$table->string('plesk_guid', 64)->nullable();
|
||||
|
||||
$table->string('hosting_plan', 100)->nullable();
|
||||
$table->string('ftp_username', 100)->nullable();
|
||||
$table->string('system_username', 100)->nullable();
|
||||
$table->string('document_root', 255)->nullable();
|
||||
|
||||
// pending -> active -> suspended -> terminated (mirrors services.status)
|
||||
$table->string('status', 20)->default('pending')->index();
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
|
||||
$table->foreign('service_id')->references('id')->on('services')->onDelete('set null');
|
||||
$table->foreign('dns_manager_server_id')->references('id')->on('dns_manager_servers')->onDelete('restrict');
|
||||
$table->foreign('dns_manager_domain_id')->references('id')->on('dns_manager_domain')->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('module_hosting_accounts');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
<?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('module_hosting_plesk_clients', function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('customer_id')->index();
|
||||
$table->unsignedBigInteger('dns_manager_server_id')->index();
|
||||
$table->unsignedInteger('plesk_client_id')->index();
|
||||
|
||||
$table->string('login', 100);
|
||||
// Plesk panel login password (Crypt::encryptString) — separate credential
|
||||
// from the FTP/hosting password, which is never stored anywhere.
|
||||
$table->text('password');
|
||||
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['dns_manager_server_id', 'customer_id'], 'hosting_plesk_clients_server_customer_unique');
|
||||
|
||||
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
|
||||
$table->foreign('dns_manager_server_id')->references('id')->on('dns_manager_servers')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('module_hosting_plesk_clients');
|
||||
}
|
||||
};
|
||||
@@ -139,6 +139,12 @@ class RolesAndPermissions extends Seeder
|
||||
'domain.destroy',
|
||||
'domain.manager',
|
||||
|
||||
// Hosting
|
||||
'hosting.view',
|
||||
'hosting.create',
|
||||
'hosting.edit',
|
||||
'hosting.destroy',
|
||||
|
||||
// Vai trò & Phân quyền
|
||||
'role.view',
|
||||
'role.create',
|
||||
|
||||
Reference in New Issue
Block a user