find($attributes['id'])); // $oldAttributes = $classInstance->getAttributes(); // $newAttributes = array_merge($oldAttributes, $attributes); // $classInstance->setRawAttributes($newAttributes); collect($attributes)->each(function ($value, $key) use ($classInstance) { $classInstance->setAttribute(Str::snake($key), $value); }); return $classInstance; } /** * @throws ApiException */ protected static function error(string $message = '系统错误', int $code = 500,\Exception $e = null) { $e && Log::error($e->getTraceAsString()); $data = ['code' => $code, 'message' => $message]; throw new ApiException($data); } }