File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -103,8 +103,6 @@ abstract class AbstractRepository implements RepositoryContract
103103 */
104104 public function __construct ()
105105 {
106- $ this ->errors = new MessageBag ;
107-
108106 $ this ->makeModel ();
109107 $ this ->boot ();
110108 }
@@ -666,7 +664,7 @@ protected function applyScope()
666664 */
667665 public function addError ($ message )
668666 {
669- $ this ->errors ->add ('message ' , $ message );
667+ $ this ->getErrors () ->add ('message ' , $ message );
670668
671669 return null ;
672670 }
@@ -678,6 +676,10 @@ public function addError($message)
678676 */
679677 public function getErrors ()
680678 {
679+ if ($ this ->errors === null ) {
680+ $ this ->errors = new MessageBag ;
681+ }
682+
681683 return $ this ->errors ;
682684 }
683685
@@ -690,7 +692,7 @@ public function getErrors()
690692 */
691693 public function getErrorMessage ($ default = '' )
692694 {
693- return $ this ->errors ->first ('message ' ) ?: $ default ;
695+ return $ this ->getErrors () ->first ('message ' ) ?: $ default ;
694696
695697 }
696698
You can’t perform that action at this time.
0 commit comments