| 1234567891011121314151617181920212223242526272829303132 |
- <?php
- namespace UCore\Validator;
- use UCore\Validator;
- use App\Models\Hp\User;
- /**
- * 关联查询,批量
- *
- */
- class ModelRelatedsValidator extends Validator
- {
- public function validate(mixed $value, array $data): bool
- {
- $list = $this->args;
- foreach ($list as $modelClass => $field){
- /**
- * @var \Illuminate\Database\Eloquent\Builder $query
- */
- $query = $modelClass::query();
- $re = $query->whereIn($field,$value)->first();
- if($re){
- return false;
- }
- }
- return false;
- }
- }
|