Esempio n. 1
0
 public function delete($id = null)
 {
     if (!is_null($id)) {
         $this->where('id', 'eq', $id);
     }
     $chunkSize = 50;
     $this->chunk($chunkSize, function ($rows) {
         foreach ($rows as $existing) {
             $url = $existing->{'@controls'}->self->href;
             $this->client->delete($url, []);
         }
     });
     return true;
 }
Esempio n. 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;
 }