value; $success = false; return response()->json(compact('description', 'success', 'msg', 'showType', 'placement')); } /** * 返回 Json 响应 * * @param bool $success 响应状态 * @param array $data 响应数据 * @param string $msg 响应内容 */ protected static function renderJson( bool $success = true, array $data = [], string $msg = '', ShopTypeEnum $showTypeEnum = ShopTypeEnum::SUCCESS_MESSAGE ): JsonResponse { $showType = $showTypeEnum->value; return response()->json(compact('data', 'success', 'msg', 'showType')); } /** * 抛出 API 数据 * * @param bool $success 响应状态 * @param mixed $data 返回数据 * @param string $msg 响应内容 * @param ShopTypeEnum $showTypeEnum */ public static function renderThrow( bool $success = true, array $data = [], string $msg = '', ShopTypeEnum $showTypeEnum = ShopTypeEnum::SUCCESS_MESSAGE ) { $showType = $showTypeEnum->value; throw new HttpResponseException(compact('data', 'success', 'msg', 'showType')); } }