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
81
81
return $ this ->getValidator ()->fails ();
82
82
}
83
83
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
+
84
99
/**
85
100
* Returns a Message Provider containing the errors for the model validation.
86
101
*
@@ -104,10 +119,7 @@ public function getErrors() : MessageProvider
104
119
*/
105
120
public function save (array $ options = [])
106
121
{
107
- if ($ this ->isInvalid ()) {
108
- throw new ValidationException ($ this ->getValidator ());
109
- }
110
-
122
+ $ this ->validate ();
111
123
return parent ::save ($ options );
112
124
}
113
125
}
You can’t perform that action at this time.
0 commit comments