master
cody 4 months ago
parent d1d97fa0b1
commit 144bfaa097

@ -226,9 +226,11 @@ class SupplyDemandController extends CommonController
SupplyDemand::where('id', $all['supply_demand_id'])->increment('view_count');
}
// 判断是否有会话,没有则创建
$dialogue = Dialogue::where('user_id', $this->getUserId())
->where('to_user_id', $all['to_user_id'])
->first();
$dialogue = Dialogue::where(function ($query) use ($all) {
$query->where('user_id', $this->getUserId())->where('to_user_id', $all['to_user_id']);
})->orWhere(function ($query) use ($all) {
$query->where('user_id', $all['to_user_id'])->where('to_user_id', $this->getUserId());
})->first();
if (empty($dialogue)) {
// 创建一条会话
$dialogue = Dialogue::create([
@ -248,10 +250,12 @@ class SupplyDemandController extends CommonController
// 有且仅有自己发的信息,则不能发再
$myMessage = Message::where('user_id', $this->getUserId())
->where('to_user_id', $all['to_user_id'])
->where('dialogue_id', $dialogue->id)
->first();
// 对方的信息
$otherMessage = Message::where('user_id', $all['to_user_id'])
->where('user_id', $this->getUserId())
->where('dialogue_id', $dialogue->id)
->first();
if ($myMessage && empty($otherMessage)) {
return $this->fail([ResponseCode::ERROR_BUSINESS, '对方回复以后才可以再次发送消息']);

@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*
@ -15,6 +14,12 @@ return new class extends Migration
{
Schema::create('calendars', function (Blueprint $table) {
$table->id();
// 数据类型
$table->tinyInteger('type')->nullable()->comment('数据类型1课程2自定义事件');
// 日期
$table->date('date')->nullable()->comment('日期');
$table->timestamps();
$table->softDeletes();
});

Loading…
Cancel
Save