clone contract UI

This commit is contained in:
glovetleong
2021-07-21 13:07:14 +08:00
parent f718ecb54f
commit 0d1bfa0188
13 changed files with 145 additions and 108 deletions
+11 -1
View File
@@ -11,7 +11,7 @@ class Contract extends Model
{
protected $table = 'contracts';
protected $appends = ['hash_id', 'contract_obligation_list'];
protected $appends = ['hash_id', 'contract_obligation_list', 'contract_entity_list'];
protected $hidden = [
'id', 'in_time_contract_template',
@@ -22,6 +22,11 @@ class Contract extends Model
return $this->hasMany('App\Models\ContractObligation', 'contract_id');
}
public function contract_entity()
{
return $this->hasMany('App\Models\ContractEntity', 'contract_id');
}
public function getHashIdAttribute()
{
return Hasher::encode('contracts', $this->id);
@@ -32,6 +37,11 @@ class Contract extends Model
return $this->contract_obligation()->get()->makeHidden(['contract_list']);
}
public function getContractEntityListAttribute()
{
return $this->contract_entity()->get()->makeHidden(['contract_list']);
}
public function getUpdatedAtAttribute($date)
{
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';