本文整理汇总了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;
}
示例2: save_
public function save_(array $options = [])
{
$this->throwValidationException = true;
$callResult = parent::save($options);
$this->throwValidationException = false;
return $callResult;
}
示例3: save
public function save(array $options = [])
{
if (!$this->beforeSave()) {
return false;
}
return parent::save($options);
}
示例4: save
public function save(array $options = array())
{
parent::save($options);
$scanUser = $this->getScansUserById();
$scanUser->updateTotal();
$scanUser->updateMostRecentScan();
}
示例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;
}
示例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);
}
示例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');
}
}
示例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();
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}