Enhance Group and Document resources; add leader and helper teacher relationships, update navigation icons, and adjust navigation sorting.

This commit is contained in:
2025-08-30 17:21:47 +05:00
parent 18e425f533
commit 710554a28d
24 changed files with 760 additions and 11 deletions

View File

@@ -0,0 +1,24 @@
<?php
namespace Database\Factories;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Teacher>
*/
class TeacherFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
'name' => $this->faker->name(),
'bio' => $this->faker->paragraph(),
];
}
}

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('teachers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('photo')->nullable();
$table->text('bio')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('teachers');
}
};

View File

@@ -0,0 +1,29 @@
<?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('groups', function (Blueprint $table) {
$table->foreignId('leader_teacher_id')->nullable()->constrained('teachers')->nullOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('groups', function (Blueprint $table) {
$table->dropForeign(['leader_teacher_id']);
$table->dropColumn('leader_teacher_id');
});
}
};

View File

@@ -0,0 +1,29 @@
<?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('group_teacher', function (Blueprint $table) {
$table->id();
$table->foreignId('group_id')->constrained()->cascadeOnDelete();
$table->foreignId('teacher_id')->constrained()->cascadeOnDelete();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('group_teacher');
}
};

View File

@@ -11,8 +11,9 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
$this->call([
UserTableSeeder::class,
TeacherSeeder::class,
]);
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Database\Seeders;
use App\Models\Teacher;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class TeacherSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
Teacher::factory(10)->create();
}
}