/** * @inheritDoc */ public function update(array $data = []) { $disk = $this->object->disk; $path = $this->object->path; $isNew = false; if (!empty($data['disk']) && $data['disk'] != $disk) { $contents = $this->removeFile(); $disk = $data['disk']; $isNew = true; if (empty($data['source'])) { $data['source'] = $contents; } unset($contents); } if (!empty($data['path'])) { $path = $data['path']; $contents = $this->removeFile(); if (empty($data['source'])) { $data['source'] = $contents; } unset($contents); } if (!empty($data['source'])) { $isNew = $isNew ?: $path != $this->object->path; $this->uploadFile($disk, $data['source'], $path, $isNew); unset($data['source']); } if (!$this->exists($disk, $path)) { throw new Exception('The file was not uploaded'); } return parent::update($data); }
/** * @inheritDoc */ public function update(array $data = []) { $column = $this->object->getParentColumnName(); $parent = null; if (isset($data[$column])) { $parent = $this->find($data[$column]); } unset($data[$column]); $response = parent::update($data); if ($parent && $parent->exists) { $this->object->makeChildOf($parent->getModel()); } elseif ($parent === 0 || $parent === "") { $this->object->makeRoot(); } return $response; }