getTableFields($model); $with = []; $whereKey = []; foreach ($whereKeys as $key) { $key = (string)$key; if ($key === 'timeKey') { continue; } if ($reflection->hasMethod('search' . Str::studly($key) . 'Attr')) { $with[] = $key; continue; } if (!$fields || in_array($key, $fields, true)) { $whereKey[] = $key; } } return [$with, $whereKey]; } protected function getTableFields($model): array { try { $model = is_object($model) ? $model : new $model(); return $model->getTableFields(); } catch (\Throwable $e) { return []; } } }