task-5 (Lessons and Scores) #5

Merged
klllst merged 16 commits from feature/task-5 into develop 2024-05-27 18:42:11 +04:00
4 changed files with 77 additions and 1 deletions
Showing only changes of commit 4cdbe1ab92 - Show all commits

17
app/Models/Lesson.php Normal file
View File

@ -0,0 +1,17 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Lesson extends Model
{
use HasFactory;
protected $fillable = [
'name',
'type',
'lesson_date',
];
}

View File

@ -12,9 +12,10 @@ return new class extends Migration
public function up(): void
{
Schema::create('student_subject', function (Blueprint $table) {
$table->id();
$table->foreignId('student_id')->constrained('students')->onDelete('cascade');
$table->foreignId('subject_id')->constrained('subjects')->onDelete('cascade');
$table->unsignedInteger('score');
$table->unsignedInteger('mark');
$table->timestamps();
});
}

View File

@ -0,0 +1,30 @@
<?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('lessons', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('type');
$table->date('lesson_date')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('lessons');
}
};

View File

@ -0,0 +1,28 @@
<?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::table('student_subject', function (Blueprint $table) {
$table->foreignId('lesson_id')->constrained('lessons')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('student_subject', function (Blueprint $table) {
$table->dropColumn('lesson_id');
});
}
};