added Lesson model

This commit is contained in:
m.zargarov 2024-05-07 17:16:34 +04:00
parent c632489cf3
commit 4cdbe1ab92
4 changed files with 77 additions and 1 deletions

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');
});
}
};