I'm trying to get the user with the highest evaluation points based on charisma and persuasion
What i have wrote so far after this i couldn't figure out how to make it work
$user = User::where('commision_id', $data['commision'])->whereHas('role', function ($q) {
$q->where('level', 2);
})->with(['evaluations' => function ($q) {
}]);
The evaluations relation migration
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');
});
So basically i have to sum the exp points based on persuasion and the exp points based on charisma then sum both of those sum values to get the highest ranking user.