mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/unity.git
synced 2026-08-28 08:44:07 +00:00
contract_obligation_contract_dependency checking on complete and accept
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Http\Rules\User;
|
||||
|
||||
use Auth;
|
||||
use App\Models\ContractObligation;
|
||||
use App\Models\Contract;
|
||||
|
||||
use App\Http\Helpers\Hasher;
|
||||
|
||||
@@ -45,9 +46,9 @@ class ContractObligationCompleteOrAcceptCheck implements Rule
|
||||
|
||||
if (!empty($contract_obligation->contract_obligation_dependency_list)) {
|
||||
foreach ($contract_obligation->contract_obligation_dependency_list as $key_2 => $row_2) {
|
||||
$depend_id = Hasher::decode('contract_obligations', $row_2->depend_contract_obligation_hash_id);
|
||||
$depend_contract_obligation_id = Hasher::decode('contract_obligations', $row_2->depend_contract_obligation_hash_id);
|
||||
$depend_contract_obligation = ContractObligation::
|
||||
where('id', $depend_id)
|
||||
where('id', $depend_contract_obligation_id)
|
||||
->first();
|
||||
|
||||
if ($this->type == 'complete') {
|
||||
@@ -70,6 +71,18 @@ class ContractObligationCompleteOrAcceptCheck implements Rule
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($contract_obligation->contract_obligation_contract_dependency_list)) {
|
||||
foreach ($contract_obligation->contract_obligation_contract_dependency_list as $key_2 => $row_3) {
|
||||
$depend_contract_id = Hasher::decode('contracts', $row_3->depend_contract_hash_id);
|
||||
$depend_contract = Contract::
|
||||
where('id', $depend_contract_id)
|
||||
->first();
|
||||
if ($depend_contract->status != config('constants.contract.status.done')) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,5 +100,8 @@ class ContractObligationCompleteOrAcceptCheck implements Rule
|
||||
if ($this->type == 'complete') {
|
||||
return config('error_code.contract_obligation_complete_error');
|
||||
}
|
||||
if ($this->type == 'accept') {
|
||||
return config('error_code.contract_obligation_accept_error');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user