예제 #1
0
파일: Order.php 프로젝트: kshar1989/dianpou
 public function save(array $options = array())
 {
     if (!$this->sn) {
         $this->sn = $this->genOrderSN();
     }
     parent::save($options);
 }
예제 #2
0
파일: User.php 프로젝트: kshar1989/dianpou
 public function save($options = [])
 {
     if ($this->isDirty()) {
         $changed = $this->getDirty();
         if ($changed['password']) {
             $this->password = \Hash::make($changed['password']);
         }
     }
     parent::save($options);
 }
예제 #3
0
 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);
 }
예제 #4
0
 /**
  * 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;
     }
 }
예제 #5
0
 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);
 }