File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed
Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -109,11 +109,32 @@ protected function setupDynamoDb()
109109
110110 public function save (array $ options = [])
111111 {
112- if (!$ this ->getKey ()) {
113- $ this ->fireModelEvent ('creating ' );
112+ $ create = !$ this ->exists ;
113+
114+ if ($ this ->fireModelEvent ('saving ' ) === false ) {
115+ return false ;
116+ }
117+
118+ if ($ create && $ this ->fireModelEvent ('creating ' ) === false ) {
119+ return false ;
114120 }
121+ if (!$ create && $ this ->fireModelEvent ('updating ' ) === false ) {
122+ return false ;
123+ }
124+
125+ $ saved = $ this ->newQuery ()->save ();
126+
127+ if (!$ saved ) {
128+ return $ saved ;
129+ }
130+
131+ $ this ->exists = true ;
132+ $ this ->wasRecentlyCreated = $ create ;
133+ $ this ->fireModelEvent ($ create ? 'created ' : 'updated ' , false );
134+
135+ $ this ->finishSave ($ options );
115136
116- return $ this -> newQuery ()-> save () ;
137+ return $ saved ;
117138 }
118139
119140 public function update (array $ attributes = [], array $ options = [])
You can’t perform that action at this time.
0 commit comments