diff --git a/application/admin/command/Crud/stubs/mixins/modelinit.stub b/application/admin/command/Crud/stubs/mixins/modelinit.stub index 329fb95c503667b9246779ccb5791d1ce6548b92..0a1c93b8916b56f67ed316ca11e528a18a80503c 100644 --- a/application/admin/command/Crud/stubs/mixins/modelinit.stub +++ b/application/admin/command/Crud/stubs/mixins/modelinit.stub @@ -2,7 +2,9 @@ protected static function init() { self::afterInsert(function ($row) { - $pk = $row->getPk(); - $row->getQuery()->where($pk, $row[$pk])->update(['{%order%}' => $row[$pk]]); + if (!$row['{%order%}']) { + $pk = $row->getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['{%order%}' => $row[$pk]]); + } }); } diff --git a/application/admin/model/UserRule.php b/application/admin/model/UserRule.php index 37ac709d076a2e33289726abed14b4c42e608118..86bb9fd47cf40a99b86e11256d9de2cbe4ac8418 100644 --- a/application/admin/model/UserRule.php +++ b/application/admin/model/UserRule.php @@ -23,8 +23,10 @@ class UserRule extends Model protected static function init() { self::afterInsert(function ($row) { - $pk = $row->getPk(); - $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + if (!$row['weigh']) { + $pk = $row->getPk(); + $row->getQuery()->where($pk, $row[$pk])->update(['weigh' => $row[$pk]]); + } }); } diff --git a/application/common/model/Category.php b/application/common/model/Category.php index d9c4f54b9bce7435e61350c38be11429fca54a31..8b4669a82e8f68d3be691fe233dd245bba4492e8 100644 --- a/application/common/model/Category.php +++ b/application/common/model/Category.php @@ -24,7 +24,9 @@ class Category extends Model protected static function init() { self::afterInsert(function ($row) { - $row->save(['weigh' => $row['id']]); + if (!$row['weigh']) { + $row->save(['weigh' => $row['id']]); + } }); }