update fix deadcode, security
This commit is contained in:
@@ -38,13 +38,4 @@ class ActivityLog extends Model
|
||||
$model->created_at = now();
|
||||
});
|
||||
}
|
||||
|
||||
public function causer()
|
||||
{
|
||||
return match ($this->causer_type) {
|
||||
'admin' => $this->belongsTo(User::class, 'causer_id'),
|
||||
'customer' => $this->belongsTo(Customer::class, 'causer_id'),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Banned extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'banned';
|
||||
protected $fillable = [
|
||||
'customer_id',
|
||||
'counter',
|
||||
'due_date'
|
||||
];
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Billing extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'billing';
|
||||
|
||||
protected $fillable = [
|
||||
'company',
|
||||
'tax',
|
||||
'address',
|
||||
'email',
|
||||
'customer_id'
|
||||
];
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Cart extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'product_id',
|
||||
'customer_id',
|
||||
'type_product',
|
||||
'price',
|
||||
'quantity',
|
||||
'months',
|
||||
'billing_cycle', // Add new field for billing cycle
|
||||
'product_pricing_id', // Add new field to link to ProductPricings
|
||||
];
|
||||
|
||||
/**
|
||||
* Get product - support both new and legacy system
|
||||
*/
|
||||
public function product()
|
||||
{
|
||||
// New flow: Check if product exists in Product table first
|
||||
if ($this->product_id) {
|
||||
$product = Product::find($this->product_id);
|
||||
if ($product) {
|
||||
return $product;
|
||||
}
|
||||
}
|
||||
|
||||
// Legacy flow: fallback to old system based on type_product
|
||||
return match ($this->type_product) {
|
||||
3 => $this->belongsTo(Hosting::class, 'product_id'),
|
||||
4 => $this->belongsTo(VPS::class, 'product_id'),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Cart belongs to Product (new system)
|
||||
*/
|
||||
public function productNew()
|
||||
{
|
||||
return $this->belongsTo(Product::class, 'product_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Cart belongs to Customer
|
||||
*/
|
||||
public function customer()
|
||||
{
|
||||
return $this->belongsTo(Customer::class, 'customer_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Cart has pricing info
|
||||
*/
|
||||
public function pricing()
|
||||
{
|
||||
return $this->belongsTo(ProductPricings::class, 'product_pricing_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Cart has many addons
|
||||
*/
|
||||
public function addons()
|
||||
{
|
||||
return $this->hasMany(CartAddon::class, 'cart_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get total price including addons
|
||||
*/
|
||||
public function getTotalPriceAttribute()
|
||||
{
|
||||
$basePrice = $this->price * $this->quantity;
|
||||
$addonsPrice = $this->addons->sum('price');
|
||||
return $basePrice + $addonsPrice;
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CartAddon extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'cart_addons';
|
||||
|
||||
protected $fillable = [
|
||||
'cart_id',
|
||||
'addon_id',
|
||||
'qty',
|
||||
'price',
|
||||
];
|
||||
|
||||
/**
|
||||
* Relationship: CartAddon belongs to Cart
|
||||
*/
|
||||
public function cart()
|
||||
{
|
||||
return $this->belongsTo(Cart::class, 'cart_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: CartAddon belongs to Addon
|
||||
*/
|
||||
public function addon()
|
||||
{
|
||||
return $this->belongsTo(Addon::class, 'addon_id');
|
||||
}
|
||||
}
|
||||
@@ -80,15 +80,6 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
'gender',
|
||||
];
|
||||
|
||||
public function updatableFill(array $data): self
|
||||
{
|
||||
$data = array_intersect_key($data, array_flip($this->updatable));
|
||||
foreach ($data as $key => $value) {
|
||||
$this->{$key} = $value;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends for API
|
||||
*/
|
||||
@@ -112,7 +103,6 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
'remember_token',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* Quan hệ với ModuleHosting (Hosting).
|
||||
*/
|
||||
@@ -137,19 +127,6 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
return $this->hasMany(ModuleVmware::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quan hệ N-N với DnsDomain (DNS Manager) qua bảng pivot dns_domain_user.
|
||||
*/
|
||||
public function dnsDomain()
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
DnsDomain::class,
|
||||
'dns_domain_user',
|
||||
'user_id',
|
||||
'domain_id',
|
||||
)->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Quan hệ với Service (tbl.services).
|
||||
*/
|
||||
@@ -222,22 +199,6 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
return $this->hasMany(Log::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Quan hệ với ModuleSnapshotLimit (Snapshot).
|
||||
*/
|
||||
public function snapShot()
|
||||
{
|
||||
return $this->hasOne(ModuleSnapshotLimit::class);
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']) {
|
||||
1 => '<span class="badge bg-success">Actived</span>',
|
||||
2 => '<span class="badge bg-secondary">De-actived</span>',
|
||||
default => '<span class="badge bg-danger">Banned</span>'
|
||||
};
|
||||
}
|
||||
|
||||
public function getEmailMarketingBoolAttribute()
|
||||
{
|
||||
return (bool) $this->email_marketing;
|
||||
@@ -248,7 +209,6 @@ class Customer extends Authenticatable implements JWTSubject
|
||||
return (bool) $this->receive_deposit;
|
||||
}
|
||||
|
||||
|
||||
public function getPointAttribute()
|
||||
{
|
||||
return (string) floor($this->total / 100);
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class CustomerLog extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'customer_log';
|
||||
|
||||
protected $fillable = [
|
||||
'customer_id',
|
||||
'action',
|
||||
'agent',
|
||||
'client_ip'
|
||||
];
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Device extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -25,9 +25,4 @@ class DnsManagerNS extends Model
|
||||
'ttl',
|
||||
'plesk_id',
|
||||
];
|
||||
|
||||
public function managerDomain()
|
||||
{
|
||||
return $this->belongsTo(DnsDomain::class, 'dns_manager_domain_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
@@ -24,15 +24,6 @@ class DnsServer extends Model
|
||||
'type',
|
||||
];
|
||||
|
||||
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>',
|
||||
};
|
||||
}
|
||||
|
||||
public function servesHosting(): bool
|
||||
{
|
||||
$type = $this->attributes['type'] ?? ServerType::DOMAIN->value;
|
||||
|
||||
@@ -21,8 +21,4 @@ class Domain extends Model
|
||||
'type_id',
|
||||
'status'
|
||||
];
|
||||
public function type()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Type::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Support\Eloquent\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Kalnoy\Nestedset\NodeTrait;
|
||||
|
||||
class Group extends Model
|
||||
{
|
||||
use HasFactory, Sluggable;
|
||||
|
||||
protected $table = "group";
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'status',
|
||||
'type_id',
|
||||
];
|
||||
|
||||
public function type()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Type::class);
|
||||
}
|
||||
|
||||
public function hostings()
|
||||
{
|
||||
return $this->hasMany(\App\Models\Hosting::class);
|
||||
}
|
||||
|
||||
public function vps()
|
||||
{
|
||||
return $this->hasMany(\App\Models\VPS::class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,27 +58,11 @@ class Invoice extends Model
|
||||
return $this->belongsTo(Service::class, 'service_id');
|
||||
}
|
||||
|
||||
|
||||
public function payment()
|
||||
{
|
||||
return $this->belongsTo(Payment::class, 'payment_method', 'id');
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Helpers
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public function getStatus(): string
|
||||
{
|
||||
return match ($this->status) {
|
||||
1 => '<span class="bg-red-100 text-red-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm dark:bg-red-900 dark:text-red-300">Chưa thanh toán</span>',
|
||||
2 => '<span class="bg-lime-100 text-lime-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm dark:bg-lime-900 dark:text-lime-300">Đã thanh toán</span>',
|
||||
3 => '<span class="bg-gray-100 text-gray-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm dark:bg-gray-900 dark:text-gray-300">Đã hủy</span>',
|
||||
4 => '<span class="bg-orange-100 text-orange-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm dark:bg-orange-900 dark:text-orange-300">Quá hạn</span>',
|
||||
default => '<span class="bg-red-100 text-red-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm dark:bg-red-900 dark:text-red-300">Không xác định</span>',
|
||||
};
|
||||
}
|
||||
|
||||
public function getStatusLabelAttribute(): string
|
||||
{
|
||||
return InvoiceStatus::from($this->status)->label();
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by ServiceAddon.
|
||||
* The invoice_addons table has been removed in the billing refactor.
|
||||
* Use ServiceAddon for configurable resources attached to a Service.
|
||||
*/
|
||||
class InvoiceAddons extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'invoice_addons';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function invoiceItem()
|
||||
{
|
||||
return $this->belongsTo(InvoiceItem::class, 'invoice_item_id');
|
||||
}
|
||||
}
|
||||
@@ -78,11 +78,6 @@ class IpPool extends Model
|
||||
return $this->belongsTo(Service::class, 'service_id');
|
||||
}
|
||||
|
||||
public function virtualMachines()
|
||||
{
|
||||
return $this->hasMany(VirtualMachines::class, 'ip_pool_id');
|
||||
}
|
||||
|
||||
public function contacts()
|
||||
{
|
||||
return $this->hasMany(IpPoolContact::class);
|
||||
|
||||
@@ -7,9 +7,4 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class IpPoolContact extends Model
|
||||
{
|
||||
protected $fillable = ['ip_pool_id', 'email', 'type'];
|
||||
|
||||
public function ipPool()
|
||||
{
|
||||
return $this->belongsTo(IpPool::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,4 @@ class Mail extends Model
|
||||
{
|
||||
return $this->belongsTo(Template::class, 'template_id');
|
||||
}
|
||||
|
||||
public function campaign()
|
||||
{
|
||||
return $this->belongsTo(MailCampaign::class, 'campaign_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,4 @@ class ModuleDatacenter extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\vCenter::class,'vcenter_id','id');
|
||||
}
|
||||
|
||||
public function hosts()
|
||||
{
|
||||
return $this->hasMany(\App\Models\ModuleHost::class, 'module_datacenter_id', 'id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,4 @@ class ModuleDnsServer extends Model
|
||||
'counter',
|
||||
'status',
|
||||
];
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->status) {
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
default => '<span class="badge bg-secondary">No Active</span>'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,15 +41,6 @@ class ModuleHosting extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleHostingServer::class,'module_server_id','id');
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']){
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
2 => '<span class="badge bg-secondary">Cancel</span>',
|
||||
default => '<span class="badge bg-danger">Pending</span>'
|
||||
};
|
||||
}
|
||||
public function scopeIsActive(Builder $query)
|
||||
{
|
||||
$query->where('active', 1);
|
||||
|
||||
@@ -19,12 +19,4 @@ class ModuleHostingServer extends Model
|
||||
'counter',
|
||||
'status'
|
||||
];
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->status) {
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
default => '<span class="badge bg-secondary">No Active</span>'
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,11 +36,4 @@ class ModuleIpAddress extends Model
|
||||
{
|
||||
$query->where('status',0);
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match($this->attributes['status']) {
|
||||
1 => '<span class="badge badge-info">Assigned</span>',
|
||||
default => '<span class="badge bg-success">Free</span>'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,13 +29,4 @@ class ModuleNetwork extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\vCenter::class, 'vcenter_id', 'id');
|
||||
}
|
||||
public function ipAddresses()
|
||||
{
|
||||
return $this->hasMany(\App\Models\ModuleIpAddress::class, 'module_network_id');
|
||||
}
|
||||
|
||||
public function ipPools()
|
||||
{
|
||||
return $this->hasMany(\App\Models\IpPool::class, 'module_network_id');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,15 +86,6 @@ class ModuleVmware extends Model
|
||||
return $this->belongsTo(\App\Models\Service::class, 'service_id');
|
||||
}
|
||||
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->status) {
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
2 => '<span class="badge bg-secondary">Cancel</span>',
|
||||
default => '<span class="badge bg-danger">Pending</span>',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* `virtual_machine_id`/`cpu`/`ram_mb` are only written when a service is
|
||||
* created directly against a known vCenter inventory row (admin "create
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by ServiceAddon.
|
||||
* The order__order_addons table has been removed in the billing refactor.
|
||||
* Use ServiceAddon for configurable resources attached to a Service.
|
||||
*/
|
||||
class OrderAddon extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $table = 'order__order_addons';
|
||||
|
||||
protected $guarded = [];
|
||||
|
||||
public function orderItem()
|
||||
{
|
||||
return $this->belongsTo(OrderItem::class, 'order_item_id');
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class OrderItem extends Model
|
||||
{
|
||||
|
||||
@@ -52,13 +52,6 @@ class Os extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleFolder::class, 'folder_id');
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']){
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
default => '<span class="badge bg-danger">De-Active</span>'
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Many-to-many relationship với Products (new table: os_product)
|
||||
*/
|
||||
|
||||
@@ -26,11 +26,4 @@ class OsGroup extends Model
|
||||
{
|
||||
return $this->hasMany(\App\Models\Os::class);
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']){
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
default => '<span class="badge bg-danger">De-Active</span>'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,4 @@ class Payment extends Model
|
||||
{
|
||||
return $this->belongsTo(\App\Models\Order::class);
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']) {
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
default => '<span class="badge bg-secondary">InActive</span>'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +74,6 @@ class Product extends Model
|
||||
return $this->belongsTo(ProductCategories::class, 'product_categories_id');
|
||||
}
|
||||
|
||||
public function servicePlan()
|
||||
{
|
||||
return $this->belongsTo(ServicePlan::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Product has many OS versions (pivot table: os_product)
|
||||
*/
|
||||
@@ -97,16 +92,6 @@ class Product extends Model
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Product has many Control Panels (for Hosting)
|
||||
*/
|
||||
public function controlPanels()
|
||||
{
|
||||
return $this->belongsToMany(ControlPanel::class, 'product_control_panel')
|
||||
->withPivot(['price_modifier', 'is_default'])
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Relationship: Product has many pricings
|
||||
*/
|
||||
@@ -148,16 +133,6 @@ class Product extends Model
|
||||
return $this->belongsTo(ModuleIpAddress::class, 'module_ip_address');
|
||||
}
|
||||
|
||||
public function provisioningHost()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleHost::class, 'module_host_id');
|
||||
}
|
||||
|
||||
public function provisioningDatastore()
|
||||
{
|
||||
return $this->belongsTo(\App\Models\ModuleDatastore::class, 'module_datastore_id');
|
||||
}
|
||||
|
||||
public function addons()
|
||||
{
|
||||
return $this->hasMany(Addon::class, 'type', 'product_type')
|
||||
|
||||
@@ -68,9 +68,4 @@ class ProductCategories extends Model
|
||||
}
|
||||
return ProductTypeEnums::tryFrom($this->type)?->label();
|
||||
}
|
||||
|
||||
public static function getTypeOptions(): array
|
||||
{
|
||||
return array_map(fn($case) => $case->value, ProductTypeEnums::cases());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ProductVMTemplates extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -59,14 +59,6 @@ class Province extends Model
|
||||
'administrative_unit_id',
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the administrative unit that owns the province.
|
||||
*/
|
||||
public function administrativeUnit()
|
||||
{
|
||||
return $this->belongsTo(AdministrativeUnit::class, 'administrative_unit_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the wards for the province.
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Traits\LogsActivity;
|
||||
use App\View\Components\Module\OsVersion;
|
||||
use Illuminate\Database\Eloquent\Concerns\HasUuids;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
@@ -116,21 +115,6 @@ class Service extends Model
|
||||
return $this->status === 'active';
|
||||
}
|
||||
|
||||
public function isPending(): bool
|
||||
{
|
||||
return $this->status === 'pending';
|
||||
}
|
||||
|
||||
public function canRetryProvisioning(): bool
|
||||
{
|
||||
return $this->isPending() && $this->retry_requested_at === null;
|
||||
}
|
||||
|
||||
public function retryRequested(): bool
|
||||
{
|
||||
return $this->retry_requested_at !== null;
|
||||
}
|
||||
|
||||
public function isExpired(): bool
|
||||
{
|
||||
return $this->expires_at !== null && $this->expires_at->isPast();
|
||||
@@ -148,10 +132,4 @@ class Service extends Model
|
||||
default => ucfirst($this->status),
|
||||
};
|
||||
}
|
||||
|
||||
/** Convenience: get an addon value by type. */
|
||||
public function getAddon(string $type): ?string
|
||||
{
|
||||
return $this->addons->firstWhere('addon_type', $type)?->addon_value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,4 @@ class ServicePlanPlesk extends Model
|
||||
'plesk_plan_name',
|
||||
'note',
|
||||
];
|
||||
|
||||
public function servicePlan()
|
||||
{
|
||||
return $this->belongsTo(ServicePlan::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,6 @@ class VirtualMachines extends Model
|
||||
return $this->belongsTo(ModuleHost::class, 'host_id');
|
||||
}
|
||||
|
||||
public function ipPool()
|
||||
{
|
||||
return $this->belongsTo(IpPool::class, 'ip_pool_id');
|
||||
}
|
||||
|
||||
public function vmware()
|
||||
{
|
||||
return $this->hasOne(ModuleVmware::class, 'vmware_id', 'vm_id');
|
||||
|
||||
@@ -7,9 +7,4 @@ use Illuminate\Database\Eloquent\Model;
|
||||
class VmProvisionLock extends Model
|
||||
{
|
||||
protected $fillable = ['customer_id', 'order_item_id', 'status'];
|
||||
|
||||
public static function isRunning(int $customerId): bool
|
||||
{
|
||||
return static::where('customer_id', $customerId)->where('status', 'running')->exists();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +67,5 @@ class Ward extends Model
|
||||
{
|
||||
return $this->belongsTo(Province::class, 'province_code', 'code');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the administrative unit that owns the ward.
|
||||
*/
|
||||
public function administrativeUnit()
|
||||
{
|
||||
return $this->belongsTo(AdministrativeUnit::class, 'administrative_unit_id');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,4 @@ class vCenter extends Model
|
||||
{
|
||||
return $this->hasMany(\App\Models\ModuleDatacenter::class, 'vcenter_id');
|
||||
}
|
||||
public function getStatus()
|
||||
{
|
||||
return match ($this->attributes['status']) {
|
||||
1 => '<span class="badge bg-success">Active</span>',
|
||||
default => '<span class="badge bg-secondary">No Active</span>'
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user