Insert

@param array $input
@return array
436935
public function insert(array $input) : array {
		if (\Application::get('flag.numbers.framework.api.enforce_rest')) {
			$temp2 = $this->get($input);
			if (!$temp2['values_loaded']) {
				return $this->save($input);
			} else {
				return [
					'success' => false,
					'error' => ['Can not create, record exists!'],
					'values' => []
				];
			}
		} else {
			return $this->save($input);
		}
	}
474767
public function with_input( array $input = null ) {
		$this->get_session()->flash_input(
			$this->clean_input( ! is_null( $input ) ? $input : $this->get_request()->input() )
		);

		return $this;
	}
49224
public static function createFromArray(array $input)
    {
        if (!empty($input['empty'])) {
            return static::createEmpty();
        }
        foreach (['lower', 'upper', 'lowerInclusive', 'upperInclusive'] as $key) {
            if (array_key_exists($key, $input)) {
                return new static(
                    array_key_exists('lower', $input) ? $input['lower'] : null,
                    array_key_exists('upper', $input) ? $input['upper'] : null,
                    array_key_exists('lowerInclusive', $input) ? $input['lowerInclusive'] : true,
                    array_key_exists('upperInclusive', $input) ? $input['upperInclusive'] : false
                );
            }
        }
        return new static(array_shift($input), array_shift($input));
    }
379392
public function import($input)
    {
        if (is_array($input)) {
            $this->fromArray($input);
        }
        else {
            $this->fromString($input);
        }

        return $this;
    }
1260270
public function create(array $input)
	{
    unset($input['_token']);

    $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
    $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId();

    $input = eloquent_array_filter_for_insert($input);
		$input = array_add($input, 'organization_id', $organizationId);
    // $input['date'] = $this->Carbon->createFromFormat($this->Lang->get('form.phpShortDateFormat'), $input['date'])->format('Y-m-d');

    $this->DB->transaction(function() use ($input, $loggedUserId, $organizationId)
		{
      $VoucherType = $this->VoucherType->create($input);

      $Journal = $this->Journal->create(array('journalized_id' => $VoucherType->id, 'journalized_type' => $this->VoucherType->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId));
      $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::voucher-type-management.addedJournal', array('VoucherType' => $VoucherType->name)), $Journal));
    });

    return json_encode(array('success' => $this->Lang->get('form.defaultSuccessSaveMessage'), 'voucherTypes' => $this->getVoucherTypes()));
  }
997147
public function prepare($input)
    {
        foreach ($input as $key => $record) {
            $this->setFieldOriginalValue($key);
            $input[$key] = $this->prepareValue($key, $record);
        }

        return $input;
    }
446181
public function addInput(Input $input)
    {
        $reflection = new \ReflectionClass($input);

        $method = 'add'.$reflection->getShortName();

        if (method_exists($this, $method)) {
            $this->$method(...array_values($input->getAttributes()));
        }
    }
832052
public function import($input)
    {
        if (false !== ($array = $this->getImportableArray($input))) {
            $this->input = array_replace_recursive($this->input, $array);
            $this->cache = [];
        }
    }
363526
public function delete(array $input)
  {
    $info = false;

    $this->DB->transaction(function() use ($input, &$info)
    {
      $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
      $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');
      $ids = $this->getAccountChildrenIds($input['id']);

      array_push($ids, $input['id']);

      if($this->JournalEntry->byAccountIds($ids)->count() > 0)
      {
        $info = $this->Lang->get('decima-accounting::account-management.accountValidationMessage');
        return;
      }

      $this->Account->byIds($ids)->each(function($Account) use ($loggedUserId, $organizationId)
      {
        $Journal = $this->Journal->create(array('journalized_id' => $Account->id, 'journalized_type' => $this->Account->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId));
        $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::account-management.accountDeletedAccount', array('account' => $Account->key . ' ' . $Account->name)), $Journal));
      });

      $this->Account->delete($ids);
    });

    if(!$info)
    {
      return json_encode(array('success' => $this->Lang->get('form.defaultSuccessDeleteMessage')));
    }
    else
    {
      return json_encode(array('info' => $info));
    }
  }
238663
public function store($input)
    {
        $this->model = $this->model->fill($input);

        $filteredInput = $this->runChecks('store', $this->model->toArray());

        if ($filteredInput) {
            $this->model->fill($filteredInput);
        }

        return $this->model->save();
    }
1086939
public function sanitize( $input ) {
		$new_input = [];
		foreach ( array_keys( (array) $input ) as $id ) {
			$new_input[ sanitize_file_name( $id ) ] = sanitize_text_field( $input[ $id ] );
		}

		return $new_input;
	}
548111
public function post(array $input) : array {
		$input[\Object\Form\Parent2::BUTTON_SUBMIT_SAVE] = true;
		$input[\Object\Form\Parent2::BUTTON_SUBMIT_POST] = true;
		$this->form->form_object->addInput($input);
		$this->form->form_object->process();
		return $this->form->form_object->apiResult();
	}
876760
public function updateOrCreate(array $input)
    {
        $this->cache->tags($this->getModel())->flush();
        return $this->repository->updateOrCreate($input);
    }
1179058
protected function encode(array $input)
	{
		// Detect the request content type, default to 'text/plain'
		$content_type = isset($this->headers['Content-Type']) ? $this->headers['Content-Type'] : $this->response_info('content_type', 'text/plain');

		// Get the correct format for the current content type
		$format = \Arr::key_exists(static::$auto_detect_formats, $content_type) ? static::$auto_detect_formats[$content_type] : null;

		switch($format)
		{
			// Format as XML
			case 'xml':
					/**
					 * If the input array has one item in the top level
					 * then use that item as the root XML element.
					 */
					if(count($input) === 1)
					{
						$base_node = key($input);
						return \Format::forge($input[$base_node])->to_xml(null, null, $base_node);
					}
					else
					{
						return \Format::forge($input)->to_xml();
					}
				break;

			// Format as JSON
			case 'json':
					return \Format::forge($input)->to_json();
				break;

			// Format as PHP Serialized Array
			case 'serialize':
					return \Format::forge($input)->to_serialize();
				break;

			// Format as PHP Array
			case 'php':
					return \Format::forge($input)->to_php();
				break;

			// Format as CSV
			case 'csv':
					return \Format::forge($input)->to_csv();
				break;

			// Format as Query String
			default:
					return http_build_query($input, null, '&');
				break;
		}
	}
7936
protected function buildSyncData(array $input)
    {
        $syncData = [];
        foreach ($input['data'] as $item) {
            $syncData[$item['id']] = ['weight' => isset($item['weight']) ? $item['weight'] : 0];
        }
        return $syncData;
    }
749632
public static function createFromArray(array $input)
    {
        if (3 != count($input)) {
            throw new InvalidArgumentException(
                sprintf("%s() expects an array with exactly three elements", __METHOD__)
            );
        }
        if (array_key_exists('A', $input) && array_key_exists('B', $input) && array_key_exists('C', $input)) {
            return new self($input['A'], $input['B'], $input['C']);
        }
        return new self(array_shift($input), array_shift($input), array_shift($input));
    }
174815
protected function replaceSpecialChars($input)
	{
		if(is_array($input))
		{
			$result = [];
			
			foreach($input as $k => $v)
			{
				$result[$k] = $this->replaceSpecialChars($v);
			}
			
			return $result;
		}
		
		return strtr($input, [
			'\n' => "\n",
			'\t' => "\t"
		]);
	}