本文整理汇总了PHP中Illuminate\Support\Arr::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::add方法的具体用法?PHP Arr::add怎么用?PHP Arr::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Arr
的用法示例。
在下文中一共展示了Arr::add方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Append new data
*
* @param string $index Unique identifier
* @param null $data
* @param bool $toAdmin If show on admin environment
* @return $this
*/
public function add($index, $data = null, $toAdmin = false)
{
if (!$this->has($index)) {
$this->data = Arr::add($this->data, $index, $data);
$this->metas = Arr::add($this->metas, $this->firstIndex($index), ['admin' => $toAdmin]);
}
return $this;
}
示例2: getAccessTokenResponse
/**
* {@inheritdoc}
*/
public function getAccessTokenResponse($code)
{
$postKey = version_compare(ClientInterface::VERSION, '6') === 1 ? 'form_params' : 'body';
$response = $this->getHttpClient()->post($this->getTokenUrl(), [$postKey => $this->getTokenFields($code)]);
$data = [];
parse_str($response->getBody(), $data);
return Arr::add($data, 'expires_in', Arr::pull($data, 'expires'));
}
示例3: addErrorMessage
/**
* Add error messages to the current array of error messages
*
* @param string $key Key to store messages against
* @param array $messages Messages to store
*
* @return void
*/
protected function addErrorMessage($key, $messages)
{
$messagesKey = $key . '.errors';
if ($key == null) {
$messagesKey = 'errors';
}
$this->errorMessages = Arr::add($this->errorMessages, $messagesKey, $messages);
}
示例4:
/**
* Add an element to an array using "dot" notation if it doesn't exist.
*
* @param array $array
* @param string $key
* @param mixed $value
* @return array
*/
function array_add($array, $key, $value)
{
return Arr::add($array, $key, $value);
}
示例5: addUpdatedAtColumn
/**
* Add the "updated at" column to an array of values.
*
* @param array $values
* @return array
*/
protected function addUpdatedAtColumn(array $values)
{
if (!$this->model->usesTimestamps()) {
return $values;
}
$column = $this->model->getUpdatedAtColumn();
return Arr::add($values, $column, $this->model->freshTimestampString());
}
示例6: parseConfig
/**
* Parse and prepare the database configuration.
*
* @param array $config
* @param string $name
* @return array
*/
protected function parseConfig(array $config, $name)
{
return Arr::add(Arr::add($config, 'prefix', ''), 'name', $name);
}
示例7: appendOption
public function appendOption($value, $label)
{
$this->options = Arr::add($this->options, $value, $label);
return $this;
}
示例8: createAttachRecord
/**
* Create a new pivot attachment record.
*
* @param int $id
* @param bool $timed
* @return array
*/
protected function createAttachRecord($id, $timed)
{
$record = parent::createAttachRecord($id, $timed);
return Arr::add($record, $this->morphType, $this->morphClass);
}
示例9: getResult
/**
* Gets results from prepared query
*
* @return null
*/
protected function getResult()
{
if ($this->query_type == 'eloquent') {
$this->result_object = $this->query->get();
$this->result_array = $this->result_object->toArray();
} else {
$this->result_object = $this->query->get();
$this->result_array = array_map(function ($object) {
return (array) $object;
}, $this->result_object);
}
if ($this->dataFullSupport) {
$walk = function ($value, $key, $prefix = null) use(&$walk, &$result_array) {
$key = !is_null($prefix) ? $prefix . "." . $key : $key;
if (is_array($value)) {
array_walk($value, $walk, $key);
} else {
$result_array = Arr::add($result_array, $key, $value);
}
};
$result_array = array();
array_walk($this->result_array, $walk);
$this->result_array = $result_array;
}
}
示例10: storeExpression
/**
* Save the expression
*
* @param string $key
* @param mixed $expression
* @return void
*/
protected function storeExpression($key, $expression)
{
if (A::has($this->expressions, $key)) {
$this->expressions = A::set($this->expressions, $key, $expression);
} else {
$this->expressions = A::add($this->expressions, $key, $expression);
}
$this->reload();
}
示例11: getHttpClient
/**
* Prepare configured http client
*
* @return GuzzleHttp\Client
* @author Sebastian
**/
protected function getHttpClient($config)
{
$guzzleConfig = Arr::get($config, 'guzzle', []);
return new HttpClient(Arr::add($guzzleConfig, 'connect_timeout', 60));
}
示例12: getTokenFields
/**
* Get the POST fields for the token request.
*
* @param string $code
* @return array
*/
protected function getTokenFields($code)
{
return Arr::add(parent::getTokenFields($code), 'grant_type', 'authorization_code');
}
示例13: addValidationOption
/**
* Add validation option.
*
* @param string $type
* @param string $key
* @param string $value
*
* @throws ValidateException
*
* @return array
*/
protected function addValidationOption($type, $key, $value)
{
$this->checkValidationTypes($type);
$this->validationOptions = Arr::add($this->validationOptions, "{$type}.{$key}", $value);
return $this->validationOptions;
}