37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
return new class extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*/
|
|
public function up(): void
|
|
{
|
|
Schema::create('attendances', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('teacher_subject_id')->nullable()->constrained('teacher_subjects');
|
|
$table->foreignId('student_id')->constrained('students');
|
|
$table->date('date');
|
|
$table->enum('status', ['present', 'absent', 'permission', 'sick']);
|
|
$table->foreignId('recorded_by')->constrained('users');
|
|
$table->string('semester');
|
|
$table->text('notes')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->unique(['teacher_subject_id', 'student_id', 'date', 'semester']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('attendances');
|
|
}
|
|
};
|