users worden nu beter geresolved
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Message;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
\App\Models\Message::all()->each(function (Message $message) {
|
||||
$msg = $message->content;
|
||||
|
||||
$msg = preg_replace_callback('/<user:([0-9]+)>/', function ($matches) {
|
||||
$userId = $matches[1];
|
||||
$user = \App\Models\User::find($userId);
|
||||
if($user){
|
||||
$userId = $user->uuid;
|
||||
}
|
||||
return "<user:$userId>";
|
||||
}, $msg);
|
||||
|
||||
if($msg != $message->content) {
|
||||
$message->update(['content' => $msg]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('uuid_base', function (Blueprint $table) {
|
||||
//
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user