public function scopeLookupKeyValue($query, $key, $value, $class_name = '', $data_type = 's')
    {
        // Lookup serialized array.
        if (is_array($value)) {
            $value = serialize($value);
            $value = self::encodeQueryValue(addslashes($value));

            $sql = sprintf(
                'payload->"$.data.command" LIKE \'%%%s\\\\\\\\";%s%%\'',
                $key,
                $value
            );

            $query->whereRaw($sql);

            return;
        }

        if ($value === false) {
            $data = sprintf(
                $data_type.':%s:\\\\\\\\"%s\\\\\\\\"',
                mb_strlen($class_name),
                self::encodeQueryValue($class_name)
            );

            $sql = sprintf(
                'payload->"$.data.command" LIKE \'%%%s\\\\\\\\";%s%%\'',
                $key,
                $data
            );
        } elseif ($value !== false) {
            if (stripos($value, '%') === false) {
                $value_length = mb_strlen($value);
            } else {
                $value_length = '%';
            }

            $data = sprintf(
                's:%s:\\\\\\\\"%s\\\\\\\\"',
                $value_length,
                $value
            );

            if (is_numeric($value)) {
                $data = sprintf('i:%s', $value);
            }

            $sql = sprintf(
                'payload->"$.data.command" LIKE \'%%%s\\\\\\\\";%s;%%\'',
                $key,
                $data
            );
        }

        $query->whereRaw($sql);
    }