Remove Interface ID and implement the lid/sid methods in __get()
This commit is contained in:
@@ -36,7 +36,7 @@ use App\Traits\{PushNew,SiteID};
|
||||
*
|
||||
* @package App\Models
|
||||
*/
|
||||
class Invoice extends Model implements IDs
|
||||
class Invoice extends Model
|
||||
{
|
||||
use PushNew,ScopeActive,SiteID;
|
||||
|
||||
@@ -109,6 +109,16 @@ class Invoice extends Model implements IDs
|
||||
'payment_items_active.payment:id,paid_at',
|
||||
];
|
||||
|
||||
public function __get($key): mixed
|
||||
{
|
||||
return match ($key) {
|
||||
'lid' => sprintf('%06s',$this->id),
|
||||
'sid' => sprintf('%02s-%04s-%s',$this->site_id,$this->account_id,$this->lid),
|
||||
|
||||
default => parent::__get($key),
|
||||
};
|
||||
}
|
||||
|
||||
/* STATIC METHODS */
|
||||
|
||||
public static function boot()
|
||||
@@ -317,28 +327,6 @@ class Invoice extends Model implements IDs
|
||||
return round(($d-Arr::get($period,'start')->diffInDays($start)-$end->diffInDays(Arr::get($period,'end')))/$d,2);
|
||||
}
|
||||
|
||||
/* INTERFACES */
|
||||
|
||||
/**
|
||||
* Invoice Local ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getLIDAttribute(): string
|
||||
{
|
||||
return sprintf('%06s',$this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoice System ID
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSIDAttribute(): string
|
||||
{
|
||||
return sprintf('%02s-%04s-%s',$this->site_id,$this->account_id,$this->getLIDAttribute());
|
||||
}
|
||||
|
||||
/* RELATIONS */
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user