Export.php 467 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace app\admin\model\examples;
  3. use think\Model;
  4. /**
  5. * Export
  6. */
  7. class Export extends Model
  8. {
  9. // 表名
  10. protected $name = 'export_example';
  11. // 自动写入时间戳字段
  12. protected $autoWriteTimestamp = true;
  13. protected static function onAfterInsert($model)
  14. {
  15. if ($model->weigh == 0) {
  16. $pk = $model->getPk();
  17. $model->where($pk, $model[$pk])->update(['weigh' => $model[$pk]]);
  18. }
  19. }
  20. }