<?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 T5nsG; Z0992: $MCyeh = ModelUtil::model('member_message')->where(array('status' => MemberMessageStatus::UNREAD))->groupBy('userId')->get(array('userId', \DB::raw('count(*) as count')))->toArray(); goto Asm6s; T5nsG: Schema::table('member_user', function (Blueprint $onV5E) { $onV5E->integer('messageCount')->nullable()->comment('未读消息数量'); }); goto Z0992; Asm6s: foreach ($MCyeh as $lLaeU) { MemberUtil::update($lLaeU['userId'], array('messageCount' => $lLaeU['count'])); } goto wNJha; wNJha: } public function down() { } }