feat: Implement DNS management with dedicated models, repositories, requests, controllers, and services, while refactoring authentication by removing Passport and Sanctum.
This commit is contained in:
@@ -6,12 +6,11 @@ use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
class Customer extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use HasFactory, HasApiTokens, HasUuids, SoftDeletes;
|
||||
use HasFactory, HasUuids, SoftDeletes;
|
||||
|
||||
protected $table = 'customers';
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DnsDomain extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'dns_manager_domain';
|
||||
|
||||
protected $fillable = [
|
||||
'domain_name',
|
||||
'user_id',
|
||||
'dns_manager_server_id',
|
||||
'is_created',
|
||||
'plesk_id',
|
||||
];
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsToMany(Customer::class, 'dns_domain_user', 'domain_id', 'customer_id')->withTimestamps();
|
||||
}
|
||||
|
||||
public function server()
|
||||
{
|
||||
return $this->belongsTo(DnsServer::class, 'dns_manager_server_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 DnsRecord 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 domain()
|
||||
{
|
||||
return $this->belongsTo(DnsDomain::class, 'dns_manager_domain_id', 'id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DnsServer extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'dns_manager_servers';
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'ip_address',
|
||||
'password',
|
||||
'username',
|
||||
'api_key',
|
||||
'status',
|
||||
];
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return match ($this->attributes['status']) {
|
||||
'activated' => '<span class="badge bg-success text-success-fg">Activated</span>',
|
||||
'Stopped' => '<span class="badge bg-danger text-danger-fg">Stopped</span>',
|
||||
default => '<span class="badge bg-secondary">Unknown</span>',
|
||||
};
|
||||
}
|
||||
|
||||
protected function scopeIsActive($query)
|
||||
{
|
||||
return $query->where('status', 'activated');
|
||||
}
|
||||
}
|
||||
+1
-3
@@ -2,17 +2,15 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Contracts\Auth\MustVerifyEmail;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Laravel\Sanctum\HasApiTokens;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
class User extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use HasApiTokens, HasFactory, Notifiable;
|
||||
use HasFactory, Notifiable;
|
||||
use HasRoles;
|
||||
|
||||
protected $table = 'user';
|
||||
|
||||
Reference in New Issue
Block a user