contract entity api

This commit is contained in:
glovetleong
2021-07-26 11:42:32 +08:00
parent 3b23ac84df
commit 247b21010e
15 changed files with 397 additions and 16 deletions
+32
View File
@@ -3,6 +3,8 @@
namespace App\Http\Rules\User;
use Auth;
use App\Models\Contract;
use App\Models\ContractEntity;
use App\Models\Entity;
use App\Models\ContractTemplate;
use App\Models\ContractTemplateObligation;
@@ -38,6 +40,36 @@ class UnderCheck implements Rule
$this->attribute = $attribute;
$value = is_array($value) ? $value : [$value];
if ($this->type == 'contract') {
foreach ($value as $key => $row) {
if(!empty($row)) {
$id = Hasher::decode('contracts', $row);
$data = Contract::
where('id', $id)
->where('user_id', Auth::guard('user-api')->user()->id)
->count();
if (!$data) {
return false;
}
}
}
}
if ($this->type == 'contract_entity') {
foreach ($value as $key => $row) {
if(!empty($row)) {
$id = Hasher::decode('contract_entities', $row);
$data = ContractEntity::
where('id', $id)
->where('user_id', Auth::guard('user-api')->user()->id)
->count();
if (!$data) {
return false;
}
}
}
}
if ($this->type == 'entity') {
foreach ($value as $key => $row) {
if(!empty($row)) {