Exemple #1
0
 public function update(array $values)
 {
     $chunkSize = 50;
     $objects = [];
     $this->chunk($chunkSize, function ($rows) use($values, &$objects) {
         foreach ($rows as $existing) {
             $url = $existing->{'@controls'}->self->href;
             $newValues = $existing;
             $this->removeMasonPropertiesFromObject($newValues);
             $options = ['json' => array_merge((array) $newValues, $values)];
             $objects[] = $this->client->update($url, $options);
         }
     });
     return $objects;
 }
Exemple #2
0
 /**
  * Perform a model update operation.
  *
  * @param  Builder  $query
  * @param  array  $options
  * @return bool|null
  */
 protected function performUpdate(Builder $query, array $options = [])
 {
     // If the updating event returns false, we will cancel the update operation so
     // developers can hook Validation systems into their models and cancel this
     // operation if the model does not pass validation. Otherwise, we update.
     if ($this->fireModelEvent('updating') === false) {
         return null;
     }
     $properties = $this->toArray();
     if ($this->selfUrl) {
         $object = self::$client->update($this->selfUrl, ['json' => $properties]);
     } else {
         $objects = $this->setKeysForSaveQuery($query)->update($properties);
         $object = reset($objects);
     }
     $this->setRawAttributes((array) $object);
     $this->fireModelEvent('updated', false);
     return $this;
 }