/** * @inheritDoc */ public function create(array $data = []) { $column = $this->object->getParentColumnName(); $parent = false; if (isset($data[$column])) { $parent = $this->find($data[$column]); } unset($data[$column]); $new_object = parent::create($data); if ($new_object->exists && $parent && $parent->exists) { $new_object->getModel()->makeChildOf($parent->getModel()); } return $new_object; }
/** * @inheritDoc */ public function create(array $data = []) { $disk = null; if (!empty($data['disk'])) { $disk = $data['disk']; } if (empty($data['path'])) { throw new Exception('A target file path must be defined'); } $path = $data['path']; if (empty($data['name'])) { $data['name'] = $path; } if (!empty($data['source'])) { $this->uploadFile($disk, $data['source'], $path); unset($data['source']); } if (!$this->exists($disk, $path)) { throw new Exception('The file was not uploaded'); } return parent::create($data); }