Browse Source

添加afterCreate

龙飞 9 months ago
parent
commit
5fd6471450
1 changed files with 13 additions and 3 deletions
  1. 13
    3
      src/SyncService.php

+ 13
- 3
src/SyncService.php View File

209
     {
209
     {
210
         // 添加本服务特有的字段, 默认值
210
         // 添加本服务特有的字段, 默认值
211
         $data = array_merge($data, $this->mapping_add);
211
         $data = array_merge($data, $this->mapping_add);
212
-        $this->_model->create($data);
212
+        $model = $this->_model->create($data);
213
+        $this->afterCreate($model->{$this->key});
213
     }
214
     }
214
 
215
 
215
     /**
216
     /**
219
     {
220
     {
220
         // 保留本地特有字段,只更新从远程获取的字段
221
         // 保留本地特有字段,只更新从远程获取的字段
221
         $meeting->update($data);
222
         $meeting->update($data);
222
-        $this->afterUpdate($meeting->id);
223
+        $this->afterUpdate($meeting->{$this->key});
223
     }
224
     }
224
 
225
 
225
     /**
226
     /**
226
-     * 更新数据
227
+     * 更新后处理数据
227
      * @param $id
228
      * @param $id
228
      * @return void
229
      * @return void
229
      */
230
      */
230
     protected function afterUpdate($id): void {
231
     protected function afterUpdate($id): void {
231
         //$this->_model->getOne($id, true);
232
         //$this->_model->getOne($id, true);
232
     }
233
     }
234
+    
235
+    /**
236
+     * 创建后处理数据
237
+     * @param $id
238
+     * @return void
239
+     */
240
+    protected function afterCreate($id): void {
241
+        //$this->_model->getOne($id, true);
242
+    }
233
 
243
 
234
     /**
244
     /**
235
      * 删除数据, 物理删除
245
      * 删除数据, 物理删除