Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * {@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'));
 }
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * 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);
 }
Ejemplo n.º 5
0
 /**
  * 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());
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
Ejemplo n.º 7
0
 public function appendOption($value, $label)
 {
     $this->options = Arr::add($this->options, $value, $label);
     return $this;
 }
Ejemplo n.º 8
0
 /**
  * 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);
 }
 /**
  * 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;
     }
 }
Ejemplo n.º 10
0
 /**
  * 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();
 }
 /**
  * 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));
 }
Ejemplo n.º 12
0
 /**
  * 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');
 }
Ejemplo n.º 13
0
 /**
  * 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;
 }