改进 将获取头像的地方的 email 改成 email_md5
This commit is contained in:
parent
2445ebcdab
commit
d5efe9b485
@ -158,7 +158,7 @@ public function user_group(): BelongsTo
|
|||||||
|
|
||||||
public function scopeBirthday()
|
public function scopeBirthday()
|
||||||
{
|
{
|
||||||
return $this->select(['id', 'name', 'birthday_at', 'email', 'created_at'])->whereMonth('birthday_at', now()->month)
|
return $this->select(['id', 'name', 'birthday_at', 'email_md5', 'created_at'])->whereMonth('birthday_at', now()->month)
|
||||||
->whereDay('birthday_at', now()->day);
|
->whereDay('birthday_at', now()->day);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ public function scopeWorkOrderId($query, $work_order_id)
|
|||||||
public function scopeWithUser($query)
|
public function scopeWithUser($query)
|
||||||
{
|
{
|
||||||
return $query->with(['user' => function ($query) {
|
return $query->with(['user' => function ($query) {
|
||||||
$query->select('id', 'name', 'email');
|
$query->select('id', 'name', 'email_md5');
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->string('email_md5')->after('email')->nullable()->comment('邮箱 MD5');
|
||||||
|
});
|
||||||
|
|
||||||
|
$count = User::count();
|
||||||
|
$i = 0;
|
||||||
|
|
||||||
|
User::chunk(100, function ($users) use (&$i, $count) {
|
||||||
|
foreach ($users as $user) {
|
||||||
|
|
||||||
|
echo sprintf('Updating %d/%d', ++$i, $count) . PHP_EOL;
|
||||||
|
|
||||||
|
$user->email_md5 = md5($user->email);
|
||||||
|
$user->saveQuietly();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('users', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('email_md5');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user