Create translations from array.

@param $group
@param $key
@param $value
@return array
184061
protected function makeRows($group, $key, $value): array
    {
        $rows = [];

        if (is_array($value)) {
            foreach ($value as $subKey => $subValue) {
                $rows[] = [
                    'key'   => $group . '.' . $key . '.' . $subKey,
                    'value' => $subValue,
                ];
            }
        } else {
            $rows[] = [
                'key'   => $group . '.' . $key,
                'value' => $value,
            ];
        }

        return $rows;
    }
496033
public static function toKeyValue($collection, $key, $value, $useDotSyntax = false)
    {
        $keyValueArray = [];
        foreach ($collection as $item) {
            $itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
            $keyValue = self::get($itemArray, $key, null, $useDotSyntax);
            $keyValueArray[$keyValue] = $itemArray[$value];
        }

        return $keyValueArray;
    }
1029919
public static function fromArray(array $value)
    {
        $language = null;
        $culture = null;

        if (!empty($value['language'])) {
            $language = $value['language'];
        } elseif ($value[0]) {
            $language = $value[0];
        }

        if (!empty($value['culture'])) {
            $culture = $value['culture'];
        } elseif ($value[1]) {
            $culture = $value[1];
        }

        return new static($language, $culture);
    }
1101250
public function pluck($value, $key = null)
    {
        return with(new static(Arr::pluck($this->items, $value, $key)))->first();
    }
1238334
private function updateTranslationGroups($groupname)
    {
    	$group = TranslationGroup::firstOrCreate(['name' => $groupname]);
    	array_push($this->translation_groups, $group);
    }
999027
public static function toKeyGroup($collection, $key, $useDotSyntax = false)
    {
        $keyGroupArray = [];
        foreach ($collection as $item) {
            $itemArray = is_array($item) ? $item : (method_exists($item, 'toArray') ? $item->toArray() : []);
            $keyValue = self::get($itemArray, $key, null, $useDotSyntax);
            $keyGroupArray[$keyValue][] = $itemArray;
        }

        return $keyGroupArray;
    }
27642
public function setTranslation($key, $locale, $value)
    {
        $this->guardAgainstNonTranslatableAttribute($key);

        $translations = $this->getTranslations($key);
        $oldValue     = $translations[$locale] ?? '';

        if ($this->hasSetMutator($key)) {
            $this->{'set'.Str::studly($key).'Attribute'}($value);
            $value = $this->attributes[$key];
        }

        $translations[$locale]  = $value;
        $this->attributes[$key] = $this->asJson($translations);

        event(new TranslationHasBeenSet($this, $key, $locale, $oldValue, $value));

        return $this;
    }
270909
private function getValue(array $values, $languages, $group, $parent = NULL)
    {
    	foreach($values as $key => $value){

			foreach($languages as $language){
				$entry = Translation::firstOrCreate([
					'key' => $key,
					'language' => $language,
					'translation_group' => $group->id,
					'parent' => $parent
				]);
				if(is_array($value)){
					$this->getValue($value, $languages, $group, $entry->id);
				} else {
					if($entry->value === NULL){
						$entry->value = $value;
						$entry->save();
					}
				}
			}
	    }
    }
809101
public function grammarExpression($key, $value)
    {
        if ($key === '!or' || $key === '!and') {
            if (!is_array($value)) {
                throw new Exception('[Norm/MongoCursor] "!or" and "!and" must have value as array.');
            }

            $newValue = array();

            foreach ($value as $v) {
                $newValue[] = $this->translateCriteria($v, true);
            }

            return array('$'.substr($key, 1), $newValue);
        }

        $splitted = explode('!', $key, 2);

        $field = $splitted[0];

        $schema = $this->collection->schema($field);

        if (strlen($field) > 0 && $field[0] === '$') {
            $field = '_'.substr($field, 1);
        }

        $operator = '$eq';
        $multiValue = false;

        if (isset($splitted[1])) {
            switch ($splitted[1]) {
                case 'like':
                    return array($field, array('$regex' => new \MongoRegex("/$value/i")));
                case 'regex':
                    return array($field, array('$regex' => new \MongoRegex($value)));
                case 'in':
                case 'nin':
                    $operator = '$'.$splitted[1];
                    $multiValue = true;
                    break;
                default:
                    $operator = '$'.$splitted[1];
                    break;
            }
        }

        if ($field === '_id') {
            if ($operator === '$eq') {
                return array($field, new MongoId($value));
            } else {
                return array($field, array($operator => new MongoId($value)));
            }
        }

        if (isset($schema)) {
            if ($multiValue) {
                if (!empty($value)) {
                    $newValue = array();
                    
                    if(!is_array($value)){
                        $value = array($value);
                    }

                    foreach ($value as $k => $v) {
                        // TODO ini quickfix buat query norm array seperti mongo
                        // kalau ada yang lebih bagus caranya bisa dibenerin
                        if (!$schema instanceof \Norm\Schema\NormArray) {
                            $newValue[] = $schema->prepare($v);
                        }
                    }
                    $value = $newValue;
                } else {
                    $value = array();
                }
            } else {
                // TODO ini quickfix buat query norm array seperti mongo
                // kalau ada yang lebih bagus caranya bisa dibenerin
                if (!$schema instanceof \Norm\Schema\NormArray) {
                    $value = $schema->prepare($value);
                }
            }

        }
        $value = $this->connection->marshall($value);

        if ($operator === '$eq') {
            return array($field, $value);
        } else {
            return array($field, array($operator => $value));
        }
    }
644476
private function hydrateArray($array, $group, $version)
    {
        foreach ($array as $key => $value) {
            $this->hydrate($value, $group, $version);
        }

        return $array;
    }
618983
public function withValue($key, $value)
    {
        $copy = $this->values;
        $copy[$key] = $value;
        return new Context($copy);
    }
339004
public function put($key, $value)
    {
        // if key exits then override
        if ($this::has($key)) {
            $setting = (new SettingModel)
                ->cached()
                ->where('key', $key)
                ->first();

            $setting->value = $value;

            return $setting->save();
        }

        return SettingModel::create([
            'key' => $key,
            'value' => $value,
        ]);
    }
17342
public function load( $locale, $group, $namespace = null )
	{
		$namespace = $namespace ?: '*';

		if ( isset( $this->messages[$namespace][$locale][$group] ) )
		{
			return $this->messages[$namespace][$locale][$group];
		}

		return [];
	}
321472
public function fetchPairs($key, $value = NULL) {
		$return = array();
		foreach ($this as $row) {
			$return[$row->$key] = $value ? $row->$value : $row->$key;
		}
		return $return;
	}
48021
protected function mutateAttributeForArray($key, $value)
    {
        $value = $this->mutateAttribute($key, $value);

        return $value instanceof Arrayable ? $value->toArray() : $value;
    }
1354273
protected function buildCondition(ConditionGroupContract $group, $key, $value)
    {

        if (is_array($value)) {
            return $group->where($key, 'in', $value);
        }

        if (is_numeric($value)) {
            return $group->where($key, '=', $value);
        }

        if (Type::isStringLike($value)) {
            return $group->where($key, 'like', "$value");
        }

        return $group->where($key, $value);

    }
570120
public function set($key, $value)
    {
        if (is_array($key) && $value === null)
            $args = $key;
        else
            $args = func_get_args();

        $path = $args;
        $value = array_pop($path);
        $type = $this->types->dget($path);
        $kpath = implode('.', $path);

        // Key is undefined, but it may be in a untyped sub-array
        if ($type === null)
        {
            $cpy = $path;
            while (count($cpy))
            {
                $last = array_pop($cpy);
                $subtype = $this->types->dget($cpy);
                if ($subtype instanceof Validator && $subtype->getType() === Type::ARRAY)
                    return parent::set($args, null);
            }
        }

        if ($type === null)
            throw new \InvalidArgumentException("Undefined key: " . $kpath);

        if ($type instanceof Dictionary)
        {
            // Subfiltering required - extract values
            if (!Functions::is_array_like($value))
                throw new \InvalidArgumentException("Value must be array at: " . $kpath);

            foreach ($value as $subkey => $subval)
            {
                $nargs = $path;
                $nargs[] = $subkey;
                $nargs[] = $subval;
                $this->set($nargs, null);
            }
            return;
        }

        if (!$type->validate($value))
        {
            $error = $type->getErrorMessage($value);
            $msg = WF::fillPlaceholders($error['msg'], $error['context'] ?? []);
            throw new \InvalidArgumentException($msg);
        }

        return parent::set($args, null);
    }