From 69a0087ca6a8091f2d7642fe2145fd8c72ab21b7 Mon Sep 17 00:00:00 2001 From: "weiken.intex" Date: Wed, 4 Aug 2021 01:07:27 +0800 Subject: [PATCH] - Hidden ID --- app/Models/Contract.php | 9 +++++++-- app/Models/ContractObligation.php | 16 ++++++++++++++-- app/Models/ContractTemplate.php | 11 ++++++++++- app/Models/ContractTemplateObligation.php | 18 +++++++++++++++++- app/Models/Entity.php | 11 ++++++++++- app/Models/EntitySignature.php | 4 ++++ app/Models/Role.php | 2 +- app/Models/User.php | 2 +- 8 files changed, 64 insertions(+), 9 deletions(-) diff --git a/app/Models/Contract.php b/app/Models/Contract.php index 82ddfac..868618e 100644 --- a/app/Models/Contract.php +++ b/app/Models/Contract.php @@ -11,10 +11,10 @@ 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_obligation_list', 'contract_entity_list']; protected $hidden = [ - 'id', 'in_time_contract_template', + 'id','user_id', 'in_time_contract_template' ]; public function contract_obligation() @@ -31,6 +31,11 @@ class Contract extends Model { return Hasher::encode('contracts', $this->id); } + + public function getUserHashIdAttribute() + { + return Hasher::encode('user', $this->user_id); + } public function getContractObligationListAttribute() { diff --git a/app/Models/ContractObligation.php b/app/Models/ContractObligation.php index facecbf..997e875 100644 --- a/app/Models/ContractObligation.php +++ b/app/Models/ContractObligation.php @@ -13,7 +13,9 @@ class ContractObligation extends Model protected $appends = [ 'hash_id', - 'contract_hash_id', + 'contract_hash_id', + 'user_hash_id', + 'contract_entity_hash_id', 'contract_list', 'contract_obligation_dependency_list', 'depend_contract_obligation_dependency_list', @@ -22,7 +24,7 @@ class ContractObligation extends Model ]; protected $hidden = [ - 'in_time_contract_obligation_template', + 'id','user_id','contract_entity_id','contract_id','in_time_contract_obligation_template', ]; public function contract() @@ -59,6 +61,16 @@ class ContractObligation extends Model { return Hasher::encode('contracts', $this->contract_id); } + + public function getContractEntityHashIdAttribute() + { + return Hasher::encode('contract_entities', $this->contract_entity_id); + } + + public function getUserHashIdAttribute() + { + return Hasher::encode('user', $this->user_id); + } public function getContractListAttribute() { diff --git a/app/Models/ContractTemplate.php b/app/Models/ContractTemplate.php index fa8bd5e..2bfc6d3 100644 --- a/app/Models/ContractTemplate.php +++ b/app/Models/ContractTemplate.php @@ -11,7 +11,11 @@ class ContractTemplate extends Model { protected $table = 'contract_templates'; - protected $appends = ['hash_id', 'contract_template_obligation_list']; + protected $appends = ['hash_id','user_hash_id', 'contract_template_obligation_list']; + + protected $hidden = [ + 'id','user_id' + ]; public function contract_template_obligation() { @@ -22,6 +26,11 @@ class ContractTemplate extends Model { return Hasher::encode('contract_templates', $this->id); } + + public function getUserHashIdAttribute() + { + return Hasher::encode('user', $this->user_id); + } public function getContractTemplateObligationListAttribute() { diff --git a/app/Models/ContractTemplateObligation.php b/app/Models/ContractTemplateObligation.php index 23c9d52..7d249ae 100644 --- a/app/Models/ContractTemplateObligation.php +++ b/app/Models/ContractTemplateObligation.php @@ -13,11 +13,17 @@ class ContractTemplateObligation extends Model protected $appends = [ 'hash_id', + 'contract_template_hash_id', + 'user_hash_id', 'contract_template_list', 'contract_template_obligation_dependency_list', 'depend_contract_template_obligation_dependency_list', 'contract_template_obligation_contract_template_dependency_list' ]; + + protected $hidden = [ + 'id','contract_template_id','user_id', + ]; public function contract_template() { @@ -43,7 +49,17 @@ class ContractTemplateObligation extends Model { return Hasher::encode('contract_template_obligations', $this->id); } - + + public function getContractTemplateHashIdAttribute() + { + return Hasher::encode('contract_template', $this->contract_template_id); + } + + public function getUserHashIdAttribute() + { + return Hasher::encode('user', $this->user_id); + } + public function getContractTemplateListAttribute() { return $this->contract_template()->get()->makeHidden(['contract_template_obligation_list']); diff --git a/app/Models/Entity.php b/app/Models/Entity.php index 93101f2..e7d622d 100644 --- a/app/Models/Entity.php +++ b/app/Models/Entity.php @@ -11,7 +11,11 @@ class Entity extends Model { protected $table = 'entities'; - protected $appends = ['hash_id', 'entity_signature_list']; + protected $appends = ['hash_id','user_hash_id', 'entity_signature_list']; + + protected $hidden = [ + 'id','user_id', + ]; public function entity_signature() { @@ -22,6 +26,11 @@ class Entity extends Model { return Hasher::encode('entities', $this->id); } + + public function getUserHashIdAttribute() + { + return Hasher::encode('user', $this->user_id); + } public function getEntitySignatureListAttribute() { diff --git a/app/Models/EntitySignature.php b/app/Models/EntitySignature.php index bbfcb74..450608d 100644 --- a/app/Models/EntitySignature.php +++ b/app/Models/EntitySignature.php @@ -12,6 +12,10 @@ class EntitySignature extends Model protected $table = 'entity_signatures'; protected $appends = ['hash_id', 'entity_list']; + + protected $hidden = [ + 'id' + ]; public function entity() { diff --git a/app/Models/Role.php b/app/Models/Role.php index d8d94cc..ac66670 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -17,7 +17,7 @@ class Role extends Model protected $appends = ['hash_id', 'permission_list']; protected $hidden = [ - 'pivot' + 'id','pivot' ]; public function getAllPermissions() diff --git a/app/Models/User.php b/app/Models/User.php index 690e308..ba69607 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -25,7 +25,7 @@ class User extends Authenticatable ]; protected $hidden = [ - 'password', + 'id','password', ]; protected $appends = ['hash_id', 'role_list', 'permission_list'];