where('type', $type)->count(); $res = true; if ($count) $res = self::where('product_id', $product_id)->where('type', $type)->delete(); if ($res) return self::insert(compact('product_id', 'result', 'change_time', 'type'), true); return $res; } public static function getResult($productId, int $type = 0) { return json_decode(self::where('product_id', $productId)->where('type', $type)->value('result'), true) ?: ['value' => []]; } public static function clearResult($productId) { return self::where('product_id', $productId)->delete(); } }