afterInsert.stub 405 B

123456789101112
  1. protected static function onAfterInsert($model)
  2. {
  3. if ($model->{%field%} == 0) {
  4. $pk = $model->getPk();
  5. if (strlen($model[$pk]) >= 19) {
  6. $model->where($pk, $model[$pk])->update(['{%field%}' => $model->count()]);
  7. } else {
  8. $model->where($pk, $model[$pk])->update(['{%field%}' => $model[$pk]]);
  9. }
  10. }
  11. }