added routes desciption to Lesson

This commit is contained in:
m.zargarov 2024-05-08 13:34:54 +04:00
parent a9ed0e58fd
commit d6778d1455
5 changed files with 13 additions and 5 deletions

View File

@ -4,7 +4,7 @@ namespace App\Enums;
enum TypeLesson: string enum TypeLesson: string
{ {
case Homework = "Домашнее задание"; case Homework = "Домашняя работа";
case Classwork = "Работа в классе"; case Classwork = "Работа в классе";
case TestClass = "Самостоятельная работа"; case TestClass = "Самостоятельная работа";
case ExamClass = "Контрольная работа"; case ExamClass = "Контрольная работа";

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Enums\TypeLesson;
use App\Http\Requests\LessonPostRequest; use App\Http\Requests\LessonPostRequest;
use App\Models\Lesson; use App\Models\Lesson;
use App\Services\ServiceInterface; use App\Services\ServiceInterface;
@ -31,7 +32,9 @@ class LessonController extends Controller
*/ */
public function create(): View public function create(): View
{ {
return view('lessons.create'); return view('lessons.create', [
'types' => TypeLesson::cases(),
]);
} }
/** /**
@ -62,6 +65,7 @@ class LessonController extends Controller
{ {
return view('lessons.edit', [ return view('lessons.edit', [
'lesson' => $lesson, 'lesson' => $lesson,
'types' => TypeLesson::cases(),
]); ]);
} }

View File

@ -14,6 +14,7 @@ class Lesson extends Model
protected $fillable = [ protected $fillable = [
'name', 'name',
'type', 'type',
'description',
'lesson_date', 'lesson_date',
'grade_id', 'grade_id',
'teacher_id', 'teacher_id',
@ -25,17 +26,17 @@ class Lesson extends Model
return $this->hasMany(Score::class); return $this->hasMany(Score::class);
} }
public function grades(): BelongsTo public function grade(): BelongsTo
{ {
return $this->belongsTo(Grade::class); return $this->belongsTo(Grade::class);
} }
public function teachers(): BelongsTo public function teacher(): BelongsTo
{ {
return $this->belongsTo(Teacher::class); return $this->belongsTo(Teacher::class);
} }
public function subjects(): BelongsTo public function subject(): BelongsTo
{ {
return $this->belongsTo(Subject::class); return $this->belongsTo(Subject::class);
} }

View File

@ -14,6 +14,7 @@ return new class extends Migration
Schema::create('lessons', function (Blueprint $table) { Schema::create('lessons', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('name'); $table->string('name');
$table->string('description')->nullable();
$table->string('type'); $table->string('type');
$table->date('lesson_date'); $table->date('lesson_date');
$table->foreignId('grade_id')->constrained('grades')->onDelete('cascade'); $table->foreignId('grade_id')->constrained('grades')->onDelete('cascade');

View File

@ -3,6 +3,7 @@
use App\Http\Controllers\GradeController; use App\Http\Controllers\GradeController;
use App\Http\Controllers\GradeSubjectController; use App\Http\Controllers\GradeSubjectController;
use App\Http\Controllers\GradeTeacherController; use App\Http\Controllers\GradeTeacherController;
use App\Http\Controllers\LessonController;
use App\Http\Controllers\StudentController; use App\Http\Controllers\StudentController;
use App\Http\Controllers\SubjectController; use App\Http\Controllers\SubjectController;
use App\Http\Controllers\SubjectTeacherController; use App\Http\Controllers\SubjectTeacherController;
@ -18,6 +19,7 @@ Route::resources([
'subjects' => SubjectController::class, 'subjects' => SubjectController::class,
'students' => StudentController::class, 'students' => StudentController::class,
'teachers' => TeacherController::class, 'teachers' => TeacherController::class,
'lessons' => LessonController::class,
]); ]);
Route::resource('teachers.subjects', SubjectTeacherController::class)->except('index'); Route::resource('teachers.subjects', SubjectTeacherController::class)->except('index');