'integer', 'updated_at' => 'integer', 'login_at' => 'integer', 'upload_at' => 'integer', 'update_at' => 'integer', 'black_at' => 'integer', ]; /** * @return \Illuminate\Database\Eloquent\Relations\HasOne */ public function user() { return $this->hasOne(UserModel::class, 'uid', 'uid'); } public static function boot() { parent::boot(); self::created(function ($model) { event(new CreatedPartner($model)); }); self::saving(function ($model) { /** @var PartnerModel $model */ $dirty = $model->getDirty(); $updatekeys = array( 'check_photo', 'photo_1_check', 'photo_2_check', 'photo_3_check', 'photo_4_check', 'voice_check', 'weixin', 'qq' ); $inter = array_intersect(array_keys($dirty), $updatekeys); if (!empty($inter)) { // 修正卡片类型 if ( 5 == $model->feed_push_type && (1 == $model->check_photo || 1 == $model->photo_1_check || 1 == $model->photo_2_check || 1 == $model->photo_3_check || 1 == $model->photo_4_check || 1 == $model->voice_check) ) { $model->feed_push_type = 3; // 提醒后补全信息回应事件 event(new CompletedInfo($model->uid)); } elseif ( 3 == $model->feed_push_type && (1 != $model->photo_src && 1 != $model->photo_1_check && 1 != $model->photo_2_check && 1 != $model->photo_3_check && 1 != $model->photo_4_check && 1 != $model->voice_check) ) { $model->feed_push_type = 5; } foreach ($inter as $v) { if (1 != $model->getOriginal($v) && 1 == $model->$v) { $model->feed_tag_cnt = 0; $model->feed_tag_like = 0; $model->wait_select = 0; $model->is_select = 0; $model->feed_pool_level = "new"; if (5 == $model->feed_push_type) { $model->feed_pool_level = "low"; } break; } elseif (1 == $model->getOriginal($v) && 1 != $model->$v) { $model->feed_tag_cnt = 0; $model->feed_tag_like = 0; $model->wait_select = 0; $model->is_select = 0; $model->feed_pool_level = "new"; if (5 == $model->feed_push_type) { $model->feed_pool_level = "low"; } break; } } if (5 == $model->feed_push_type) { $model->feed_pool_level = "low"; } } if ("low" == $model->feed_pool_level) { if (2 != $model->wait_low_pool) { $model->wait_low_pool = 1; } } else { $model->wait_low_pool = 0; } }); self::saved(function ($model) { $fields = ['photo_src', 'photo_1', 'photo_2', 'photo_3', 'photo_4']; foreach ($fields as $field) { if ($model->isDirty($field)) { PartnerBeautyUser::updateOrCreate( ['partner_id' => $model->id, 'field' => $field], ['uid' => $model->uid, 'replaced_at' => 0, 'original_photo' => ($model->{$field} ?: '')] ); } } }); self::updated(function (/** @var PartnerModel $model */ $model) { event(new UpdatedPartner($model)); if ($model->isDirty(['feed_pool_level'])) { // 卡片信息流层级池改变 event(new PartnerFeedPoolChange($model)); } }); } }