contract obligation contract dependency generate

This commit is contained in:
glovetleong
2021-07-20 21:28:32 +08:00
parent bc1a7091eb
commit f718ecb54f
3 changed files with 46 additions and 8 deletions
+16 -3
View File
@@ -15,7 +15,8 @@ class ContractTemplateObligation extends Model
'hash_id',
'contract_template_list',
'contract_template_obligation_dependency_list',
'depend_contract_template_obligation_dependency_list'
'depend_contract_template_obligation_dependency_list',
'contract_template_obligation_contract_template_dependency_list'
];
public function contract_template()
@@ -33,6 +34,11 @@ class ContractTemplateObligation extends Model
return $this->hasMany('App\Models\ContractTemplateObligationDependency', 'depend_contract_template_obligation_id');
}
public function contract_template_obligation_contract_template_dependency()
{
return $this->hasMany('App\Models\ContractTemplateObligationContractTemplateDependency', 'contract_template_obligation_id');
}
public function getHashIdAttribute()
{
return Hasher::encode('contract_template_obligations', $this->id);
@@ -46,17 +52,24 @@ class ContractTemplateObligation extends Model
public function getContractTemplateObligationDependencyListAttribute()
{
return $this->contract_template_obligation_dependency()
->where('status', config('constants.contract_template_obligation.status.active'))
->where('status', config('constants.contract_template_obligation_dependency.status.active'))
->get()->makeHidden(['contract_template_obligation_list', 'depend_contract_template_obligation_list']);
}
public function getDependContractTemplateObligationDependencyListAttribute()
{
return $this->depend_contract_template_obligation_dependency()
->where('status', config('constants.contract_template_obligation.status.active'))
->where('status', config('constants.contract_template_obligation_dependency.status.active'))
->get()->makeHidden(['contract_template_obligation_list', 'depend_contract_template_obligation_list']);
}
public function getContractTemplateObligationContractTemplateDependencyListAttribute()
{
return $this->contract_template_obligation_dependency()
->where('status', config('constants.contract_template_obligation_contract_template_dependency.status.active'))
->get()->makeHidden(['contract_template_obligation_list']);
}
public function getUpdatedAtAttribute($date)
{
return $date ? Carbon::parse($date)->timezone('Asia/Kuala_Lumpur')->format('Y-m-d') : '';