TimestampBehavior::class, 'attributes' => [ ActiveRecord::EVENT_BEFORE_INSERT => ['created_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'] ] ] ]; } /** * @inheritdoc */ public function rules() { return [ [['store_id', 'user_id', 'child_id', 'row', 'col', 'area_key', 'created_at', 'updated_at'], 'integer'], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'store_id' => '店铺id', 'user_id' => '用户id', 'child_id' => '下级id', 'row' => '行', 'col' => '列', 'area_key' => '区域 key', 'created_at' => '创建时间', ]; } public static function createUserStringCodeArea($store_id, $user_id, $parent_id, $row, $col, $area_key) { $model = new self(); $model->store_id = $store_id; $model->user_id = $parent_id; $model->child_id = $user_id; $model->row = $row; $model->col = $col; $model->area_key = $area_key; $model->save(); $all_parent_node_ids = UserStringCode::getAllParentNodeIds($user_id); // 增加所有上级对应的位置 foreach ($all_parent_node_ids as $parent_node_id) { // if ($parent_node_id == $to_user_id) return; } } }