feat: Add DNS management resources and importer
- Implemented DomainCollection, DomainDetailResource, DomainNSCollection, DomainNSResource, and DomainResource for handling DNS domain and record data. - Created VpsServiceCollection and VpsServiceResource for VPS service management. - Added DnsManagerNS and DnsManagerUser models to represent DNS records and user associations. - Developed AdminZoneDnsSqlImporter for importing DNS data from SQL dumps, including customer and DNS domain records. - Added migration scripts to update the customers table with new fields and sync foreign key references for DNS tables. - Created a migration preview document outlining the mapping and schema changes for the admin zone DNS import.
This commit is contained in:
@@ -26,6 +26,7 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
|
||||
protected $fillable = [
|
||||
'fullname',
|
||||
'username',
|
||||
'avatar',
|
||||
'address',
|
||||
'state',
|
||||
@@ -35,6 +36,7 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
'company',
|
||||
'phone',
|
||||
'email',
|
||||
'email_verified_at',
|
||||
'email_verify',
|
||||
'email_hash',
|
||||
'email_marketing',
|
||||
@@ -43,6 +45,7 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
'front_identity_number',
|
||||
'back_identity_number',
|
||||
'password',
|
||||
'type',
|
||||
'credit',
|
||||
'total',
|
||||
'total_pending',
|
||||
@@ -55,6 +58,7 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
|
||||
protected $updatable = [
|
||||
'fullname',
|
||||
'username',
|
||||
'phone',
|
||||
'company',
|
||||
'address',
|
||||
@@ -82,6 +86,7 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
|
||||
protected $casts = [
|
||||
'gender' => \App\Enums\Client\ClientGender::class,
|
||||
'email_verified_at' => 'datetime',
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -215,6 +220,11 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
return (string) floor($this->total / 100);
|
||||
}
|
||||
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return $this->fullname;
|
||||
}
|
||||
|
||||
public function getCmndBeforeAttribute()
|
||||
{
|
||||
return $this->front_identity_number ?? '';
|
||||
|
||||
@@ -30,11 +30,21 @@ class DnsDomain extends Model
|
||||
return $this->belongsToMany(Customer::class, 'dns_domain_user', 'domain_id', 'user_id')->withTimestamps();
|
||||
}
|
||||
|
||||
public function users()
|
||||
{
|
||||
return $this->customer();
|
||||
}
|
||||
|
||||
public function server()
|
||||
{
|
||||
return $this->belongsTo(DnsServer::class, 'dns_manager_server_id', 'id');
|
||||
}
|
||||
|
||||
public function ns()
|
||||
{
|
||||
return $this->hasMany(DnsManagerNS::class, 'dns_manager_domain_id', 'id');
|
||||
}
|
||||
|
||||
public function record()
|
||||
{
|
||||
return $this->hasMany(DnsRecord::class, 'dns_manager_domain_id', 'id');
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DnsManagerNS extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'dns_manager_ns';
|
||||
|
||||
protected $fillable = [
|
||||
'dns_manager_domain_id',
|
||||
'name',
|
||||
'type',
|
||||
'type_valid',
|
||||
'priority',
|
||||
'weight',
|
||||
'port',
|
||||
'service_name',
|
||||
'protocol',
|
||||
'value',
|
||||
'ttl',
|
||||
'plesk_id',
|
||||
];
|
||||
|
||||
public function managerDomain()
|
||||
{
|
||||
return $this->belongsTo(DnsDomain::class, 'dns_manager_domain_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DnsManagerUser extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'dns_domain_user';
|
||||
|
||||
protected $fillable = [
|
||||
'domain_id',
|
||||
'user_id',
|
||||
];
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'user_id', 'id');
|
||||
}
|
||||
|
||||
public function domain()
|
||||
{
|
||||
return $this->belongsTo(DnsDomain::class, 'domain_id', 'id');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user