parent
d995294e9f
commit
d9b2f706eb
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
class Dialogue extends SoftDeletesModel
|
||||||
|
{
|
||||||
|
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->hasOne(User::class, 'id', 'user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toUser()
|
||||||
|
{
|
||||||
|
return $this->hasOne(User::class, 'id', 'to_user_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supplyDemand(){
|
||||||
|
return $this->hasOne(SupplyDemand::class, 'id', 'supply_demand_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
Schema::table('dialogues', function (Blueprint $table) {
|
||||||
|
$table->comment('会话列表');
|
||||||
|
$table->id();
|
||||||
|
// 用户id
|
||||||
|
$table->integer('user_id')->nullable()->comment('用户id');
|
||||||
|
// 接收人id
|
||||||
|
$table->integer('to_user_id')->nullable()->comment('接收人id');
|
||||||
|
// 需求id
|
||||||
|
$table->integer('supply_demand_id')->nullable()->comment('需求id');
|
||||||
|
// 消息内容
|
||||||
|
$table->text('last_content')->nullable()->comment('最后一条消息消息内容');
|
||||||
|
$table->timestamps();
|
||||||
|
$table->softDeletes();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
Schema::table('dialogues', function (Blueprint $table) {
|
||||||
|
//
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in new issue