This commit is contained in:
glovetleong
2021-08-05 14:01:33 +08:00
parent 9f5224bc73
commit e3b6c69718
17 changed files with 215 additions and 26 deletions
+21 -2
View File
@@ -11,10 +11,19 @@ class Contract extends Model
{
protected $table = 'contracts';
protected $appends = ['hash_id', 'contract_obligation_list', 'contract_entity_list'];
protected $appends = [
'hash_id',
'user_hash_id',
'contract_template_hash_id',
'contract_obligation_list',
'contract_entity_list'
];
protected $hidden = [
'id', 'in_time_contract_template',
'id',
'user_id',
'contract_template_id',
'in_time_contract_template'
];
public function contract_obligation()
@@ -32,6 +41,16 @@ class Contract extends Model
return Hasher::encode('contracts', $this->id);
}
public function getUserHashIdAttribute()
{
return Hasher::encode('users', $this->user_id);
}
public function getContractTemplateHashIdAttribute()
{
return Hasher::encode('contract_templates', $this->contract_template_id);
}
public function getContractObligationListAttribute()
{
return $this->contract_obligation()->get()->makeHidden(['contract_list']);