【发布时间】:2021-04-09 16:25:57
【问题描述】:
我正在尝试根据魅力和说服力让用户获得最高评价分
在此之后我写的到目前为止我无法弄清楚如何使它工作
$user = User::where('commision_id', $data['commision'])->whereHas('role', function ($q) {
$q->where('level', 2);
})->with(['evaluations' => function ($q) {
}]);
评估关系迁移
Schema::create('evaluations', function (Blueprint $table) {
$table->id();
$table->boolean('charisma')->default(false);
$table->boolean('persuasion')->default(false);
$table->boolean('politics')->default(false);
$table->boolean('heat')->default(false);
$table->string('title');
$table->integer('hl')->nullable();
$table->integer('exp')->nullable();
$table->unsignedBigInteger('user_id');
$table->timestamps();
$table->index('user_id');
});
所以基本上我必须将基于说服力的 exp 点和基于魅力的 exp 点相加,然后将这两个总和值相加以获得最高排名的用户。
【问题讨论】: