Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit e8e33eb

Browse files
committed
Restoring save() compatibility with original method signature
1 parent dcbf1bc commit e8e33eb

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

src/LaravelBook/Ardent/Ardent.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -540,19 +540,20 @@ public function validate(array $rules = array(), array $customMessages = array()
540540
}
541541

542542
/**
543-
* Save the model to the database.
543+
* Save the model to the database. Is used by {@link save()} and {@link forceSave()} as a way to DRY code.
544544
*
545545
* @param array $rules
546546
* @param array $customMessages
547547
* @param array $options
548548
* @param Closure $beforeSave
549549
* @param Closure $afterSave
550-
* @param bool $force Forces saving invalid data. Defaults to false; when true has the same effect as calling
551-
* {@link Ardent::forceSave()}.
550+
* @param bool $force Forces saving invalid data.
551+
552552
* @return bool
553+
* @see Ardent::save()
553554
* @see Ardent::forceSave()
554555
*/
555-
public function save(array $rules = array(),
556+
protected function internalSave(array $rules = array(),
556557
array $customMessages = array(),
557558
array $options = array(),
558559
Closure $beforeSave = null,
@@ -575,6 +576,27 @@ public function save(array $rules = array(),
575576
}
576577
}
577578

579+
/**
580+
* Save the model to the database.
581+
*
582+
* @param array $rules
583+
* @param array $customMessages
584+
* @param array $options
585+
* @param Closure $beforeSave
586+
* @param Closure $afterSave
587+
*
588+
* @return bool
589+
* @see Ardent::forceSave()
590+
*/
591+
public function save(array $rules = array(),
592+
array $customMessages = array(),
593+
array $options = array(),
594+
Closure $beforeSave = null,
595+
Closure $afterSave = null
596+
) {
597+
return $this->internalSave($rules, $customMessages, $options, $beforeSave, $afterSave, false);
598+
}
599+
578600
/**
579601
* Force save the model even if validation fails.
580602
*
@@ -592,9 +614,10 @@ public function forceSave(array $rules = array(),
592614
Closure $beforeSave = null,
593615
Closure $afterSave = null
594616
) {
595-
return $this->save($rules, $customMessages, $options, $beforeSave, $afterSave, true);
617+
return $this->internalSave($rules, $customMessages, $options, $beforeSave, $afterSave, true);
596618
}
597619

620+
598621
/**
599622
* Add the basic purge filters
600623
*

0 commit comments

Comments
 (0)