whereIn($primaryId, $value); } else { $_model = $model::query()->where(['t1.' . $primaryId => $value]); } $this->value = is_array($value) ? json_encode($value, JSON_UNESCAPED_UNICODE) : $value; $this->_relation = $relation->bindIdentification(md5($model . '_' . $primaryId . '_' . $this->value), $_model); $this->model = $model; } /** * @param $name * @param $arguments * @return static */ public function __call($name, $arguments) { if (!method_exists($this, $name)) { $key = $this->model . '_' . $this->primaryId . '_' . $this->value; $this->_relation->getQuery($this->reKey())->$name(...$arguments); } else { call_user_func([$this, $name], ...$arguments); } return $this; } /** * @return string */ protected function reKey(): string { return md5($this->model . '_' . $this->primaryId . '_' . $this->value); } /** * @param $name * @return mixed */ public function __get($name): mixed { if (empty($this->value)) { return null; } return $this->get(); } }