I'm having some condition(given below) to increment value by 1 in column('pass_number') of database table('quizzes'):
'quizzes':
Schema::create('quizzes', function (Blueprint $table) {
$table->id();
$table->string('qname');
$table->text('description');
$table->text('subcategory');
$table->text('by');
$table->text('by_username');
$table->text('profileUrl');
$table->integer('minutes');
$table->integer('cutoff');
$table->integer('pass_number')->default(0)->nullable();
$table->timestamps();
});
condition:
$cutoff1 = DB::table('quizzes')
->where('id', '=', $quizId)
->value('cutoff');
if ($percentage > $cutoff1) {
DB::table('quizzes')
->where('id', $quizId)
->update([
'pass_number' => DB::raw('pass_number + 1')
]);
}
I'm able to get increment in 'pass_number' but on page refresh I want to stop it.
*$percentage I'm getting from user's performance in particular quiz.