Removed redundant functions from Invoice, optimised Invoice tables
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Models\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Arr;
|
||||
use Leenooks\Carbon as LeenooksCarbon;
|
||||
|
||||
/**
|
||||
* Class SSL (Service)
|
||||
@@ -76,9 +77,9 @@ class SSL extends Type
|
||||
/**
|
||||
* Return the Certificate Expiry Date
|
||||
*/
|
||||
public function getServiceExpireAttribute(): ?Carbon
|
||||
public function getServiceExpireAttribute(): ?LeenooksCarbon
|
||||
{
|
||||
return $this->cert ? Carbon::createFromTimestamp($this->crt_parse->get('validTo_time_t')) : NULL;
|
||||
return $this->cert ? LeenooksCarbon::createFromTimestamp($this->crt_parse->get('validTo_time_t')) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Models\Service;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Leenooks\Carbon as LeenooksCarbon;
|
||||
|
||||
use App\Interfaces\ServiceItem;
|
||||
use App\Models\{Account,Service};
|
||||
@@ -63,7 +63,7 @@ abstract class Type extends Model implements ServiceItem
|
||||
return $this->service->offering->contract_term;
|
||||
}
|
||||
|
||||
public function getServiceExpireAttribute(): ?Carbon
|
||||
public function getServiceExpireAttribute(): ?LeenooksCarbon
|
||||
{
|
||||
return $this->expire_at ?: $this->service->invoice_next_at;
|
||||
}
|
||||
@@ -80,6 +80,17 @@ abstract class Type extends Model implements ServiceItem
|
||||
|
||||
/* ATTRIBUTES */
|
||||
|
||||
/**
|
||||
* We need to cast some dates to LeenooksCarbon to get access to startOfHalf()/endOfHalf() methods
|
||||
*
|
||||
* @param $value
|
||||
* @return LeenooksCarbon
|
||||
*/
|
||||
public function getExpireAtAttribute($value): LeenooksCarbon
|
||||
{
|
||||
return LeenooksCarbon::create($value);
|
||||
}
|
||||
|
||||
public function getTypeAttribute()
|
||||
{
|
||||
return strtolower((new \ReflectionClass($this))->getShortName());
|
||||
|
Reference in New Issue
Block a user