当前位置: 首页>>代码示例>>PHP>>正文


PHP Eloquent::save方法代码示例

本文整理汇总了PHP中Eloquent::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Eloquent::save方法的具体用法?PHP Eloquent::save怎么用?PHP Eloquent::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Eloquent的用法示例。


在下文中一共展示了Eloquent::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * @return boolean true
  * @throws ValidationException
  */
 public function save()
 {
     $this->isValid();
     $this->entity->fill($this->prepareData($this->data));
     $this->entity->save();
     return true;
 }
开发者ID:iscnorena,项目名称:report,代码行数:11,代码来源:BaseManager.php

示例2: save_

 public function save_(array $options = [])
 {
     $this->throwValidationException = true;
     $callResult = parent::save($options);
     $this->throwValidationException = false;
     return $callResult;
 }
开发者ID:daegon,项目名称:laravel-model-validation,代码行数:7,代码来源:Model.php

示例3: save

 public function save(array $options = [])
 {
     if (!$this->beforeSave()) {
         return false;
     }
     return parent::save($options);
 }
开发者ID:denaje,项目名称:laravel-goodies,代码行数:7,代码来源:BaseModel.php

示例4: save

 public function save(array $options = array())
 {
     parent::save($options);
     $scanUser = $this->getScansUserById();
     $scanUser->updateTotal();
     $scanUser->updateMostRecentScan();
 }
开发者ID:p-tricky,项目名称:CAEWeb,代码行数:7,代码来源:Scan.php

示例5: save

 /**
  * 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;
 }
开发者ID:hungdo89,项目名称:file-manager,代码行数:13,代码来源:BaseModel.php

示例6: save

 /**
  *	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);
 }
开发者ID:krues8dr,项目名称:madison,代码行数:21,代码来源:Group.php

示例7: save

 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');
     }
 }
开发者ID:gabemiller,项目名称:project-dv,代码行数:10,代码来源:Tag.php

示例8: save

 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();
 }
开发者ID:e-gob,项目名称:api-feriados,代码行数:11,代码来源:entity.php

示例9: 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);
 }
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:11,代码来源:UuidModel.php

示例10: save

 /**
  *	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);
 }
开发者ID:krues8dr,项目名称:madison,代码行数:25,代码来源:User.php

示例11: save

 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;
 }
开发者ID:marmaray,项目名称:OLD-laravel-France-website,代码行数:17,代码来源:forummessage.php

示例12: save

 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;
 }
开发者ID:basdog22,项目名称:laracms,代码行数:21,代码来源:Lara.php

示例13: save

 /**
  * 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;
 }
开发者ID:e-gob,项目名称:api-instituciones-v2,代码行数:29,代码来源:MetaEloquent.php

示例14: save

 /**
  * 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);
 }
开发者ID:amnah,项目名称:laravel-user,代码行数:33,代码来源:User.php

示例15: updateProfile

 /**
  * Update existent profile
  *
  * @param \Eloquent $profile
  * @return \Eloquent
  */
 public function updateProfile($profile)
 {
     $profile->fill(get_object_vars($this->adapterProfile));
     $profile->save();
     return $profile;
 }
开发者ID:jacob1237,项目名称:laravelhybridauth,代码行数:12,代码来源:HybridAuth.php


注:本文中的Eloquent::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。