58 lines
1.3 KiB
PHP
58 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Traits\LogsActivity;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class ModuleHosting extends Model
|
|
{
|
|
use HasFactory, LogsActivity;
|
|
|
|
protected $table = 'module_hosting';
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'order_id',
|
|
'customer_id',
|
|
'first_payment',
|
|
'next_payment',
|
|
'next_due_date',
|
|
'next_invoice',
|
|
'module_server_id',
|
|
'server_domain_id',
|
|
'username',
|
|
'password',
|
|
'status'
|
|
];
|
|
|
|
public function customer()
|
|
{
|
|
return $this->belongsTo(\App\Models\Customer::class);
|
|
}
|
|
|
|
public function order()
|
|
{
|
|
return $this->belongsTo(\App\Models\Order::class);
|
|
}
|
|
public function server()
|
|
{
|
|
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);
|
|
}
|
|
}
|