新增聊天室发送图片功能

This commit is contained in:
2026-04-12 14:04:18 +08:00
parent d2f08eb2dd
commit 00b9396dea
10 changed files with 547 additions and 42 deletions
@@ -0,0 +1,44 @@
<?php
/**
* 文件功能:为聊天消息表补充图片消息存储字段
*/
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* 聊天消息图片字段迁移
* 为消息表增加图片类型、原图、缩略图与原始文件名字段。
*/
return new class extends Migration
{
/**
* 执行迁移,补充图片消息类型与图片路径字段。
*/
public function up(): void
{
Schema::table('messages', function (Blueprint $table) {
$table->string('message_type', 20)->default('text')->after('action')->comment('消息类型:text/image/expired_image');
$table->string('image_path', 255)->nullable()->after('message_type')->comment('聊天图片原图相对路径');
$table->string('image_thumb_path', 255)->nullable()->after('image_path')->comment('聊天图片缩略图相对路径');
$table->string('image_original_name', 255)->nullable()->after('image_thumb_path')->comment('聊天图片原始文件名');
});
}
/**
* 回滚迁移,移除聊天图片相关字段。
*/
public function down(): void
{
Schema::table('messages', function (Blueprint $table) {
$table->dropColumn([
'message_type',
'image_path',
'image_thumb_path',
'image_original_name',
]);
});
}
};