entity api

This commit is contained in:
glovetleong
2021-07-01 13:54:29 +08:00
parent 2b65de855a
commit bf8a18a4fd
8 changed files with 367 additions and 4 deletions
+16
View File
@@ -3,6 +3,7 @@
namespace App\Http\Rules\User;
use Auth;
use App\Models\Entity;
use App\Models\ContractTemplate;
use App\Models\ContractTemplateObligation;
@@ -37,6 +38,21 @@ class UnderCheck implements Rule
$this->attribute = $attribute;
$value = is_array($value) ? $value : [$value];
if ($this->type == 'entity') {
foreach ($value as $key => $row) {
if(!empty($row)) {
$id = Hasher::decode('entities', $row);
$data = Entity::
where('id', $id)
->where('user_id', Auth::guard('user-api')->user()->id)
->count();
if (!$data) {
return false;
}
}
}
}
if ($this->type == 'contract_template') {
foreach ($value as $key => $row) {
if(!empty($row)) {