File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed
Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,21 @@ public function isInvalid() : bool
8181 return $ this ->getValidator ()->fails ();
8282 }
8383
84+ /**
85+ * Used to validate the model.
86+ *
87+ * @throws \Illuminate\Validation\ValidationException
88+ * Thrown if the model is not valid.
89+ *
90+ * @return void
91+ */
92+ public function validate () : void
93+ {
94+ if ($ this ->isInvalid ()) {
95+ throw new ValidationException ($ this ->getValidator ());
96+ }
97+ }
98+
8499 /**
85100 * Returns a Message Provider containing the errors for the model validation.
86101 *
@@ -104,10 +119,7 @@ public function getErrors() : MessageProvider
104119 */
105120 public function save (array $ options = [])
106121 {
107- if ($ this ->isInvalid ()) {
108- throw new ValidationException ($ this ->getValidator ());
109- }
110-
122+ $ this ->validate ();
111123 return parent ::save ($ options );
112124 }
113125}
You can’t perform that action at this time.
0 commit comments