<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use ModStart\Core\Dao\ModelUtil; use Module\Member\Type\MemberMessageStatus; use Module\Member\Util\MemberUtil; class ModifyMemberUserMessageCount extends Migration { public function up() { goto T1D5O; ZWNFY: $sX2oK = ModelUtil::model('member_message')->where(array('status' => MemberMessageStatus::UNREAD))->groupBy('userId')->get(array('userId', \DB::raw('count(*) as count')))->toArray(); goto IVYlf; IVYlf: foreach ($sX2oK as $lpVAI) { MemberUtil::update($lpVAI['userId'], array('messageCount' => $lpVAI['count'])); } goto ktZFn; T1D5O: Schema::table('member_user', function (Blueprint $GocOS) { $GocOS->integer('messageCount')->nullable()->comment('未读消息数量'); }); goto ZWNFY; ktZFn: } public function down() { } }