예제 #1
0
 /**
  * @return boolean true
  * @throws ValidationException
  */
 public function save()
 {
     $this->isValid();
     $this->entity->fill($this->prepareData($this->data));
     $this->entity->save();
     return true;
 }
예제 #2
0
 public function save_(array $options = [])
 {
     $this->throwValidationException = true;
     $callResult = parent::save($options);
     $this->throwValidationException = false;
     return $callResult;
 }
예제 #3
0
 public function save(array $options = [])
 {
     if (!$this->beforeSave()) {
         return false;
     }
     return parent::save($options);
 }
예제 #4
0
파일: Scan.php 프로젝트: p-tricky/CAEWeb
 public function save(array $options = array())
 {
     parent::save($options);
     $scanUser = $this->getScansUserById();
     $scanUser->updateTotal();
     $scanUser->updateMostRecentScan();
 }
예제 #5
0
 /**
  * Overrided save method of Model to validate before save
  *
  * @return boolean
  */
 public function save(array $options = array())
 {
     if ($this->validate($this->attributes)) {
         $this->attributes = self::trimData($this->attributes);
         return parent::save($options);
     }
     return false;
 }
예제 #6
0
파일: Group.php 프로젝트: krues8dr/madison
 /**
  *	Save.
  *
  *	Override Eloquent save() method
  *		Runs $this->beforeSave()
  *		Unsets:
  *			* $this->validationErrors
  *			* $this->rules
  *
  *	@param array $options
  *	$return bool
  */
 public function save(array $options = array())
 {
     if (!$this->beforeSave()) {
         return false;
     }
     //Don't want Group model trying to save validationErrors field.
     unset($this->validationErrors);
     return parent::save($options);
 }
예제 #7
0
 public function save(array $options = array())
 {
     $validator = \Validator::make(array('name' => $this->name), array('name' => 'required|min:1'));
     if ($validator->passes()) {
         $this->slug = TaggingUtil::slug($this->name);
         parent::save($options);
     } else {
         throw new \Exception('Tag Name is required');
     }
 }
예제 #8
0
 public function save()
 {
     //Se transforma el objeto a un arreglo para ser validado
     $data = $this->to_array();
     $v = Validator::make($data, $this->rules);
     if ($v->fails()) {
         $this->errors = $v->errors;
         return false;
     }
     return parent::save();
 }
 public function save(array $options = [])
 {
     if (!$this->exists) {
         $existing = $this->findUnique();
         if ($existing) {
             $this->{$this->primaryKey} = $existing->{$this->primaryKey};
             $this->exists = true;
         }
     }
     return parent::save($options);
 }
예제 #10
0
파일: User.php 프로젝트: krues8dr/madison
 /**
  *	Save.
  *
  *	Override Eloquent save() method
  *		Runs $this->beforeSave()
  *		Unsets:
  *			* $this->validationErrors
  *			* $this->rules
  *
  * @param array $options
  *
  * @return bool
  */
 public function save(array $options = array())
 {
     if (!$this->beforeSave()) {
         return false;
     }
     //Don't want user model trying to save validationErrors field.
     //	TODO: I'm sure Eloquent can handle this.  What's the setting for ignoring fields when saving?
     unset($this->validationErrors);
     unset($this->rules);
     unset($this->verify);
     return parent::save($options);
 }
 public function save()
 {
     $isNew = !$this->exists;
     if ($isNew) {
         $this->category->nb_posts++;
         $this->category->save();
         $this->topic->nb_messages++;
         Auth::user()->nb_messages++;
         Auth::user()->save();
         $this->user_id = Auth::user()->id;
     }
     parent::save();
     $this->topic->updated_at = $this->updated_at;
     $this->topic->save();
     Forumview::where('topic_id', '=', $this->forumtopic_id)->delete();
     return $this;
 }
예제 #12
0
파일: Lara.php 프로젝트: basdog22/laracms
 public function save(array $options = array())
 {
     if (!$this->exists()) {
         parent::save();
     }
     $langs = Languages::all();
     foreach ($langs as $lang) {
         $translation = Translations::find($this->table . "_" . $this->id . "_" . strtolower($lang->code));
         if ($lang->code == Config::get('cms.currlang.code') || !isset($translation->exists)) {
             //check if translation exists
             if (isset($translation->exists)) {
             } else {
                 $translation = new Translations();
             }
             $translation->id = $this->table . "_" . $this->id . "_" . strtolower($lang->code);
             $translation->translation = json_encode($this->getAttributes());
             $translation->save();
         }
     }
     return;
 }
예제 #13
0
 /**
  * Guarda el modelo actual y la metadata asociada
  *
  * @param array $options
  * @return $this
  */
 public function save(array $options = array())
 {
     parent::save($options);
     if ($this->exclude_metadata) {
         return $this;
     }
     //Se elimina la metadata actual
     foreach ($this->metadata as $metadata) {
         DB::table('custom_field_' . $metadata->type)->where('id', '=', $metadata->custom_field_value_id)->delete();
     }
     DB::table('custom_field_pivot')->where('content_id', '=', $this->id)->delete();
     if (isset($options['metadata'])) {
         foreach ($options['metadata'] as $key => $metadata) {
             $customFieldType = CustomField::find(intval(str_replace('customfield-', '', $key)));
             $modelName = 'CustomField' . $this->to_camel_case($customFieldType->type);
             $metadataModel = new $modelName();
             $metadataModel->value = $metadata;
             $metadataModel->save();
             DB::table('custom_field_pivot')->insert(array('custom_field_type_id' => $customFieldType->id, 'custom_field_value_id' => $metadataModel->id, 'content_id' => $this->id));
         }
     }
     return $this;
 }
예제 #14
0
파일: User.php 프로젝트: amnah/laravel-user
 /**
  * Modified save
  * @var array $options
  * @return bool
  */
 public function save(array $options = array())
 {
     // trim fillable fields
     foreach ($this->fillable as $attribute) {
         $this->{$attribute} = trim($this->{$attribute});
     }
     // set old password if user left empty
     if (empty($this->password)) {
         $this->password = $this->getOriginal("password");
     } elseif ($this->isDirty("password")) {
         $this->password = Hash::make($this->password);
     }
     // set null fields
     $nullFields = array("banned_at", "ban_reason");
     foreach ($nullFields as $nullField) {
         if (isset($this->attributes[$nullField]) and !$this->attributes[$nullField]) {
             $this->attributes[$nullField] = null;
         }
     }
     // unset temp fields
     $unsetFields = array("oldPassword", "password_confirmation");
     foreach ($unsetFields as $unsetField) {
         if (isset($this->attributes[$unsetField])) {
             unset($this->attributes[$unsetField]);
         }
     }
     return parent::save($options);
 }
예제 #15
0
 /**
  * Update existent profile
  *
  * @param \Eloquent $profile
  * @return \Eloquent
  */
 public function updateProfile($profile)
 {
     $profile->fill(get_object_vars($this->adapterProfile));
     $profile->save();
     return $profile;
 }
 /**
  * Store the eloquent model that is passed in
  * @param  Eloquent $model The Eloquent Model
  * @return void
  */
 protected function storeEloquentModel($model)
 {
     if ($model->getDirty()) {
         $model->save();
     } else {
         $model->touch();
     }
 }
예제 #17
0
파일: Post.php 프로젝트: ycms/corcel
 public function save(array $options = array())
 {
     if (isset($this->attributes[$this->primaryKey])) {
         $this->meta->save($this->attributes[$this->primaryKey]);
     }
     return parent::save($options);
 }
예제 #18
0
파일: Doc.php 프로젝트: iaincollins/madison
 public function save(array $options = array())
 {
     if (empty($this->slug)) {
         $this->slug = $this->getSlug();
     }
     return parent::save($options);
 }
예제 #19
0
 /**
  * Overriding save to add descriptor automatically.
  *
  * @return the saved object.
  */
 public function save(array $options = array())
 {
     // Associating descriptor.
     $widgetDescriptor = WidgetDescriptor::where('type', $this->getType())->first();
     /* Checking descriptor. */
     if ($widgetDescriptor === null) {
         throw new DescriptorDoesNotExist("The descriptor for " . get_class($this) . " does not exist", 1);
     }
     // Assigning descriptor.
     $this->descriptor()->associate($widgetDescriptor);
     // Calling parent.
     parent::save($options);
     // Always saving settings to keep integrity.|
     $this->saveSettings(array(), FALSE);
     $this->checkIntegrity(FALSE);
     /* Saving integrity/settings.
      * Please note, that the save won't hit the db,
      * if no change has been made to the model.
      */
     return parent::save();
 }
예제 #20
0
 public function save()
 {
     parent::save();
 }
예제 #21
0
파일: DbTitle.php 프로젝트: samirios1/niter
 /**
  * Updates provided model with all provided values
  * using array keys as model attribute name and
  * array values as attribute value.
  * 
  * @param  Eloquent $model
  * @param  array $values
  * @return void
  */
 private function updateModelAttr($model, array $values, $pivot = false)
 {
     $updates = array_except($values, array('char_name', 'pivot_id'));
     foreach ($updates as $k => $v) {
         if ($v === '') {
             $v = null;
         }
         $model->{$k} = $v;
     }
     if ($pivot) {
         $this->updatePivot($values);
     }
     $model->save();
 }
예제 #22
0
 /**
  * Force Save
  *    attempts to save model even if it doesn't validate
  *
  * @param $rules:array
  * @param $messages:array
  * @return Aware|bool
  */
 public function force_save($rules = array(), $messages = array(), $onForceSave = null)
 {
     // validate the model
     $this->valid($rules, $messages);
     // execute onForceSave
     $before = is_null($onForceSave) ? $this->onForceSave() : $onForceSave($this);
     // save regardless of the result of validation
     return $before ? parent::save() : false;
 }
예제 #23
0
파일: BaseModel.php 프로젝트: AniartUA/crm
 public function save(array $attributes = array())
 {
     $this->validateOrFail();
     return parent::save($attributes);
 }
 public function saveWithMessage(Forummessage $message)
 {
     $this->user_id = Auth::user()->id;
     $incSlug = 0;
     $originalSlug = $this->slug;
     $this->sticky = false;
     do {
         try {
             parent::save();
             $incSlug = 0;
         } catch (Exception $e) {
             if ($e->getCode() == 23000) {
                 $incSlug++;
             }
             $this->slug = $originalSlug . '-' . $incSlug;
         }
     } while ($incSlug != 0);
     $this->category->nb_topics++;
     $this->category->save();
     $message->forumtopic_id = $this->id;
     $message->forumcategory_id = $this->forumcategory_id;
     $message->save();
     return $this;
 }
예제 #25
0
 public function save()
 {
     parent::save();
     $this->update_balance();
 }
 public function save(\Eloquent $modelClassInstance)
 {
     return $modelClassInstance->save();
 }
예제 #27
0
 function save()
 {
     $existing = $this->exists;
     $result = parent::save();
     // only caching updates of existing models because newly inserted model might
     // not have all the table's fielsd (some can be set from default values) which
     // might cause Undefined Index and other errors.
     $result and $existing and static::cache($this);
     return $result;
 }
예제 #28
0
 /**
  * @param $className
  * @param $parameters
  * @param null $objectId
  * @return ParseResponse
  * @throws \Exception
  */
 public function save($className, $parameters, $objectId = null)
 {
     $values = array();
     // if update, try to get the current object at first
     if ($objectId) {
         $this->object = $this->object->findOrFail($objectId);
     }
     foreach ($parameters as $key => $val) {
         if (in_array($key, $this->columns)) {
             if (is_array($val) && ($operation = array_get($val, '__op'))) {
                 switch ($operation) {
                     case "Increment":
                         $val = $this->object->{$key} ? $this->object->{$key} + $val['amount'] : $val['amount'];
                         break;
                     case "decrement":
                         $val = $this->object->{$key} - $val['amount'];
                         break;
                     case "Delete":
                         $val = null;
                         break;
                     case "Batch":
                         //                            $ops = $val['ops'];
                         //                            foreach ($ops as $ops_key => $ops_val) {
                         //                                if ($ops_val['__op'] == 'AddRelation') {
                         //                                    foreach ($ops_val['objects'] as $objects_key => $objects_val) {
                         //                                        $relation_type = $objects_val['__type'];
                         //                                        $relation_class_name = $objects_val['className'];
                         //                                        $relation_class_name = ParseHelperClass::removeUnderscoreFromClassName($relation_class_name);     // to remove '_' character if founded in the name of class _User
                         //                                        $relation_objectId = $objects_val['objectId'];
                         //                                        $relation_object = ParseHelperClass::createObject($relation_class_name);
                         //                                        $updatedAt = '';
                         //
                         //                                        if (!$relation_object) {
                         //                                            return ParseHelperClass::error_message_return('105');
                         //                                        }
                         //
                         //                                        $object->find($objectId)->$key()->sync([$relation_objectId], false);
                         //
                         //                                        $relation_data_of_object = $object::find(60)->$key()->where($relation_class_name . '_id',
                         //                                            '=', $relation_objectId)->get();
                         //
                         //                                        foreach ($relation_data_of_object as $relation_data) {
                         //                                            $updatedAt = $relation_data->pivot->createdAt;
                         //                                        }
                         //                                    }
                         //
                         //                                    return array(
                         //                                        "updatedAt" => Carbon::parse($updatedAt)->format('Y-m-d\TH:i:s.z\Z')
                         //                                    );
                         //                                }
                         //                            }
                         break;
                 }
             }
             $values[$key] = $val;
         } elseif (in_array($key, $this->relations)) {
             //
         } else {
             if ($key != "ACL") {
                 ParseHelper::throwException('210', $key);
             }
         }
     }
     $this->object->fill($values);
     try {
         $event = $this->object->getKey() ? 'update' : 'insert';
         \Event::fire("before.{$event}." . $this->object->getTable(), $this->object);
         $this->object->save();
         //create new object
         // now we can attach the relations
         foreach ($parameters as $key => $val) {
             if (in_array($key, $this->relations)) {
                 if ($operation = array_get($val, '__op')) {
                     switch ($operation) {
                         case "Delete":
                             $this->object->{$key}()->delete($val);
                             break;
                     }
                 } elseif ($this->object->{$key}() instanceof BelongsTo) {
                     $this->object->{$key}()->associate($val);
                 } elseif (!$this->object->{$key}() instanceof BelongsTo) {
                     $this->object->{$key}()->save($val);
                 } else {
                     ParseHelper::throwException(105);
                 }
             }
         }
         \Event::fire("after.{$event}." . $this->object->getTable(), $this->object);
     } catch (\Exception $ex) {
         ParseHelper::throwException(141, $ex->getMessage());
     }
 }
예제 #29
0
 public function save()
 {
     parent::save();
     return $this->create_or_update_transaction();
 }
예제 #30
0
 /**
  * Updates an instance with the fields given
  * but only if the field values are different
  * than what is already in the database
  *
  * @param  Eloquent $instance
  * @param  array	$fields
  * @return void
  */
 protected function updateInstance($instance, $fields)
 {
     $changed = false;
     foreach ($fields as $field => $value) {
         if ($instance->{$field} != $value) {
             $changed = true;
             $instance->{$field} = $value;
         }
     }
     if ($changed) {
         $instance->save();
     }
     return $instance;
 }