feat: Lernapp mit Mathe/Deutsch/Englisch, Münzsystem und Belohnungen
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->enum('role', ['admin', 'child'])->default('child')->after('email');
|
||||
$table->unsignedInteger('points')->default(0)->after('role');
|
||||
});
|
||||
}
|
||||
public function down(): void {
|
||||
Schema::table('users', fn(Blueprint $t) => $t->dropColumn(['role','points']));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('subjects', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('icon')->default('📚');
|
||||
$table->string('color')->default('blue');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('subjects'); }
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('questions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('subject_id')->constrained()->onDelete('cascade');
|
||||
$table->text('question_text');
|
||||
$table->enum('type', ['multiple_choice', 'number_input'])->default('multiple_choice');
|
||||
$table->unsignedTinyInteger('difficulty')->default(1);
|
||||
$table->unsignedTinyInteger('points_value')->default(5);
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('questions'); }
|
||||
};
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('answer_options', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('question_id')->constrained()->onDelete('cascade');
|
||||
$table->string('text');
|
||||
$table->boolean('is_correct')->default(false);
|
||||
$table->unsignedTinyInteger('sort_order')->default(0);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('answer_options'); }
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('question_attempts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('question_id')->constrained()->onDelete('cascade');
|
||||
$table->boolean('is_correct');
|
||||
$table->unsignedTinyInteger('points_earned')->default(0);
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('question_attempts'); }
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('rewards', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('description')->nullable();
|
||||
$table->string('icon')->default('🎁');
|
||||
$table->unsignedInteger('points_cost');
|
||||
$table->unsignedInteger('minutes')->nullable();
|
||||
$table->boolean('active')->default(true);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('rewards'); }
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {
|
||||
public function up(): void {
|
||||
Schema::create('reward_redemptions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->foreignId('reward_id')->constrained()->onDelete('cascade');
|
||||
$table->enum('status', ['pending','approved','rejected'])->default('pending');
|
||||
$table->unsignedInteger('points_spent');
|
||||
$table->string('note')->nullable();
|
||||
$table->timestamp('resolved_at')->nullable();
|
||||
$table->foreignId('resolved_by')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('reward_redemptions'); }
|
||||
};
|
||||
Reference in New Issue
Block a user