public function save(array $options = array()) { if (!$this->sn) { $this->sn = $this->genOrderSN(); } parent::save($options); }
public function save($options = []) { if ($this->isDirty()) { $changed = $this->getDirty(); if ($changed['password']) { $this->password = \Hash::make($changed['password']); } } parent::save($options); }
public function save(array $options = array()) { if ($this->file && !$this->id) { if (!$this->file instanceof UploadFile) { $file = new UploadFile(["file_name" => $this->file['file_name'], "file" => $this->file['file_path']]); $file->save(); $this->file_id = $file->id; unset($this->file); } } parent::save($options); }
/** * Save model or fail by showing errors. * * @param App\Models\Model $model * @return void */ public function saveOrFail(Model $model) { if (!$model->save()) { $class = class_basename($model); $console = $this instanceof Seeder ? $this->command : $this; $errors = implode("\n- ", $model->getErrors()->all()); $console->error("\n{$class} could not be seeded:"); $console->line('- ' . $errors); $console->comment("\n{$class} attributes:"); $console->line($model->toJson(JSON_PRETTY_PRINT)); exit; } }
public function save(array $options = array()) { if ($this->file instanceof UploadedFile || strlen($this->file) > 255) { if ($this->file instanceof UploadedFile) { $this->file_name = $this->file->getClientOriginalName(); $this->file_type = $this->file->getClientMimeType(); $this->file_size = $this->file->getClientSize(); $data = File::get($this->file); } else { list($type, $data) = explode(';', $this->file); list(, $this->file_type) = explode(':', $type); list(, $data) = explode(',', $data); $data = base64_decode($data); $this->file_size = strlen($data); } $path = date('Y/m/d/') . md5(uniqid() . '-' . $this->file_name) . '.' . File::extension($this->file_name); Storage::put($path, $data); $this->file_path = $path; unset($this->file); } return parent::save($options); }