laravel - musonza/聊天供应商买家切换器定制
问题描述
在我的系统中,一个用户可以是供应商或买方或两者。对于消息传递,我正在使用 laravel musonza 聊天包。两个参与者可以相互交流。但是如何将用户消息分隔为买方或供应商。这意味着需要在单击买家时进行切换,然后根据消息显示为买家消息联系人列表,当我切换到供应商时,然后根据消息显示为供应商消息联系人。这是我目前的数据库设计......
Schema::create(ConfigurationManager::CONVERSATIONS_TABLE, function (Blueprint $table) {
$table->bigIncrements('id');
$table->boolean('private')->default(true);
$table->boolean('direct_message')->default(false);
$table->text('data')->nullable();
$table->timestamps();
});
Schema::create(ConfigurationManager::PARTICIPATION_TABLE, function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('conversation_id')->unsigned();
$table->bigInteger('messageable_id')->unsigned();
$table->string('messageable_type');
$table->text('settings')->nullable();
$table->timestamps();
$table->unique(['conversation_id', 'messageable_id', 'messageable_type'], 'participation_index');
$table->foreign('conversation_id')
->references('id')
->on(ConfigurationManager::CONVERSATIONS_TABLE)
->onDelete('cascade');
});
Schema::create(ConfigurationManager::MESSAGES_TABLE, function (Blueprint $table) {
$table->bigIncrements('id');
$table->text('body');
$table->bigInteger('conversation_id')->unsigned();
$table->bigInteger('participation_id')->unsigned()->nullable();
$table->string('type')->default('text');
$table->timestamps();
$table->foreign('participation_id')
->references('id')
->on(ConfigurationManager::PARTICIPATION_TABLE)
->onDelete('set null');
$table->foreign('conversation_id')
->references('id')
->on(ConfigurationManager::CONVERSATIONS_TABLE)
->onDelete('cascade');
});
Schema::create(ConfigurationManager::MESSAGE_NOTIFICATIONS_TABLE, function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('message_id')->unsigned();
$table->bigInteger('messageable_id')->unsigned();
$table->string('messageable_type');
$table->bigInteger('conversation_id')->unsigned();
$table->bigInteger('participation_id')->unsigned();
$table->boolean('is_seen')->default(false);
$table->boolean('is_sender')->default(false);
$table->boolean('flagged')->default(false);
$table->timestamps();
$table->softDeletes();
$table->index(['participation_id', 'message_id'], 'participation_message_index');
$table->foreign('message_id')
->references('id')
->on(ConfigurationManager::MESSAGES_TABLE)
->onDelete('cascade');
$table->foreign('conversation_id')
->references('id')
->on(ConfigurationManager::CONVERSATIONS_TABLE)
->onDelete('cascade');
$table->foreign('participation_id')
->references('id')
->on(ConfigurationManager::PARTICIPATION_TABLE)
->onDelete('cascade');
});
请帮我这样做。先感谢您 :) 。
解决方案
推荐阅读
- python - 在 python 中建模充电和供电电池
- python - 仅在表格的一部分上进行计算
- javascript - 如何发布 JavaScript 函数
- javascript - 使用 Google Script 在 Google Forms 中提交时获取地理位置
- java - Selenium Java 类中的 javax.net.ssl.SSLHandshakeException
- html - 我在移动设备上的菜单在 safari 上不起作用
- php - Symfony\Component\Debug\Exception\FatalThrowableError:参数 1 传递给 Tymon\JWTAuth\JWTGuard::login()
- git - 删除一个分支会搞乱从它创建的新分支吗?
- android - build.gradle (app) 中的 buildTypes 参数 (buildConfigField) 是否按字母顺序排序?
- c# - 从另一个类获取 tabControl1.SelectedIndex