1234567891011121314151617181920212223242526272829 |
- <?php
- namespace app\admin\model;
- use think\Model;
- /**
- * FacilityType
- */
- class FacilityType extends Model
- {
- // 表名
- protected $name = 'facility_type';
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = true;
- protected static function onAfterInsert($model)
- {
- if ($model->weigh == 0) {
- $pk = $model->getPk();
- if (strlen($model[$pk]) >= 19) {
- $model->where($pk, $model[$pk])->update(['weigh' => $model->count()]);
- } else {
- $model->where($pk, $model[$pk])->update(['weigh' => $model[$pk]]);
- }
- }
- }
- }
|