add
This commit is contained in:
12
app/admin/library/crud/stubs/mixins/model/afterInsert.stub
Normal file
12
app/admin/library/crud/stubs/mixins/model/afterInsert.stub
Normal file
@@ -0,0 +1,12 @@
|
||||
|
||||
protected static function onAfterInsert($model): void
|
||||
{
|
||||
if (is_null($model->{%field%})) {
|
||||
$pk = $model->getPk();
|
||||
if (strlen($model[$pk]) >= 19) {
|
||||
$model->where($pk, $model[$pk])->update(['{%field%}' => $model->count()]);
|
||||
} else {
|
||||
$model->where($pk, $model[$pk])->update(['{%field%}' => $model[$pk]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user